oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.24k stars 1.07k forks source link

Error: ORA-01461: can bind a LONG value only for insert into a LONG column #1577

Closed jashanbaatth closed 1 year ago

jashanbaatth commented 1 year ago

Creating table using this query -> CREATE TABLE sample (id NUMBER, firstfield VARCHAR2(3 char),secondfield VARCHAR(4000 char))

And inserting data using query ->

result = await connection1.execute( INSERT INTO "SAMPLE"("FIRSTFIELD","SECONDFIELD") VALUES(:1,:2) RETURNING "ID" into :3, ['李振藩','李小龍李小龍',{type: oracledb.STRING, dir: oracledb.BIND_OUT}], // Bind values { autoCommit: true, outFormat: oracledb.OBJECT } // Override the default, non-autocommit behavior );

It works fine in oracledb@5.5.0 but getting error in oracledb@6.0.0 :- Error: ORA-01461: can bind a LONG value only for insert into a LONG column

What bind value or changes I have to do, to make it work?

oracledb 6.0.0 app.txt

cjbj commented 1 year ago

Start by upgrading to 6.0.1.

sharadraju commented 1 year ago

@jashanbaatth Thanks for testing node-oracledb. In your attached file, app.txt, there is a minor error. You need to initialize connection2 as connection2 = await oracledb.getConnection(dbConfig);

I have tested this in 6.0.1 and there are no errors thrown with the Thick or Thin modes. This might be a duplicate of #1554 which was fixed in 6.0.1.

So please upgrade to 6.0.1 and test again as @cjbj suggested :).

Here is my output


Rows inserted: 1
{
  metaData: [
    {
      name: 'ID',
      dbType: [DbType DB_TYPE_NUMBER],
      nullable: true,
      precision: 0,
      scale: -127,
      dbTypeName: 'NUMBER',
      fetchType: [DbType DB_TYPE_NUMBER]
    },
    {
      name: 'FIRSTFIELD',
      dbType: [DbType DB_TYPE_VARCHAR],
      nullable: true,
      byteSize: 12,
      dbTypeName: 'VARCHAR2',
      fetchType: [DbType DB_TYPE_VARCHAR]
    },
    {
      name: 'SECONDFIELD',
      dbType: [DbType DB_TYPE_VARCHAR],
      nullable: true,
      byteSize: 4000,
      dbTypeName: 'VARCHAR2',
      fetchType: [DbType DB_TYPE_VARCHAR]
    }
  ],
  rows: [ { ID: null, FIRSTFIELD: '李振藩', SECONDFIELD: '李小龍李小龍' } ]
}
sharadraju commented 1 year ago

I am going to close this as duplicate of #1554 based on my previous comment. Please feel free to re-open this, if you are still facing the issue.