oracle / node-oracledb

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

Unable to use SEQUENCE NEXTVAL with INSERTS? #363

Closed mrchess closed 8 years ago

mrchess commented 8 years ago

I'm trying a very simple scenario of running this:

var sql = "INSERT INTO TEST_TABLE (ID) VALUES (TEST_TABLE_SEQ.nextval)";
oracle.connection.execute(sql, null, function(err, result) {
  ...
});

But I keep getting [Error: NJS-006: invalid type for parameter 1].

Is there a different way to utilize nextval? Basically I can't create a trigger on my sequence due to our local conventions, so I have to manually use nextval.

mrchess commented 8 years ago

Fwiw when I run the same SQL query in my SQLDeveloper console, it works.

mrchess commented 8 years ago

Ugh. Of course. The issue was i am passing null instead of an empty object {}. I originally thought the Error was referencing an error in the SQL statement.

Correct code:

oracle.connection.execute(sql, {},...) // <- supposed to be {}