0

Environment:

  • Oracle DB (12c)
  • C# application to call the db

The expected outcome is to add new row into a table and return an id column which is auto-incremented using a sequence.

The caller is a c# application which uses executeScalar to execute the sql command.

I use this sql script:

DECLARE
  NEW_ID NUMBER;

BEGIN
  INSERT INTO Users
  (username)
  VALUES ('newName')
  RETURNING userId INTO NEW_ID;
END;

which seems to be executing and does insert the new row.

The issue

The issue is that when this script is executed from the c# application using executeScalar method, it should return the first column of the first row of the returned result. Instead of receiving a value, i receive null (not DBNull).

Is the 'RETURNING' keyword not meant to be used for scalar queries or does the issue creeps somewhere else?


EDIT:

The trigger that is used to increment the column:

enter image description here

Mario
  • 767
  • 1
  • 14
  • 42

0 Answers0