Getting Pk on insert

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
degas
Posts: 77
Joined: Mon 16 Feb 2009 18:36
Location: Argentina

Getting Pk on insert

Post by degas » Wed 24 Nov 2010 17:49

I am using DevArt DataSets and i want to recover the value of the primary key when a record is inserted. In the datase there is a trigger with a sequence.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 26 Nov 2010 14:55

You should add the RETURNING clause to your insert statement. For this, please refer to the Using DataSet Wizard tutorial: on the 3d step select your data table and press the "Configure commands" button, navigate to the "Command Generator" tab, press the "Get Table Fields" button, in the "Refreshing" column select a checkbox against your autoincrement field and clear all other checkboxes in this column, in the Options area check "With refresh SQL" for insert command, press the "Generate Commands" button. As a result, the insert statement will include the RETURNING clause for your autoincrement field.

Post Reply