Skip to content

autoCommit is not working to for multiple queries #1255

@cddm-gh

Description

@cddm-gh

Hi I have this small program that first checks if something exists on a table and if it doesn't it tries to insert it, the first query executes fine but when is time to insert the program fails with error: Error: NJS-012: encountered invalid bind data type in parameter 2, if I remove the 'autoCommit:true' and put: await oracle.execute('COMMIT WORK', db) on the line after [pmigradosId] = result.outBinds.pmigradosId; it works but I'm not sure if that the right way to do it. I'm guiding with this example: https://github.com/oracle/node-oracledb/blob/master/examples/insert1.js by using multiple inserts and commit on the last one to finish the transaction successfully and also with the answer from this question: https://stackoverflow.com/questions/56356869/use-transaction-in-node-oracledb

Code Here

CREATE TABLE "PMIGRADOS" 
   (	"COD_PMIGRADOS" NUMBER NOT NULL ENABLE, 
	"FECHA" DATE NOT NULL ENABLE, 
	"HORARIO" DATE, 
	"FECHA_ENTREGA" DATE, 
	"TRANSFER" VARCHAR2(1) NOT NULL ENABLE, 
	"ESTADO" VARCHAR2(1) NOT NULL ENABLE, 
	"NUMERO_CARGA" VARCHAR2(20) NOT NULL ENABLE, 
	"CODPRO" VARCHAR2(4) NOT NULL ENABLE, 
	"COD_DEPOSITO" VARCHAR2(10) NOT NULL ENABLE, 
	"USUARIO" VARCHAR2(20), 
	"HORARIO_FIN" DATE, 
	 PRIMARY KEY ("COD_PMIGRADOS")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "OPT_DATOS"  ENABLE
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 0 INITRANS 1 MAXTRANS 255 
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "OPT_DATOS" ;
  1. Run node and show the output of:
process.platform: 'darwin'
process.version: 'v10.20.0'
process.arch: 'x64'
require('oracledb').versionString: '3.1.2'
  1. What is your Oracle Database version?
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions