Using SQLInsert with identity column and refreshing after insert
Posted: Mon 01 Apr 2013 22:21
I am in the process of migrating from Oracle to SQL Server 2012. I have used Unidac 4.6.11. I was hoping that moving database platforms would be pretty straightforward if I use standard SQL to do my queries.
This is an example of a problem I am having when inserting records. I have a table called Person with a primary key called person_id. In SQL Server person_id is set up as an identify column. Here is the query object setup:
When connected to Oracle:
For an Oracle connection, after posting an inserted record and the record is refreshed, it shows the new value for person_id.
But connected SQL Server, when posting an inserted record, I get an error that says "cannot insert explicit value for identity column in table person when identity_insert is set to OFF".
Is there a way to insert into a table with an identity column in SQL Server so that the UniDac query object behaves the same as the Oracle insertion (refreshing after insert) without needing to change the queries?
This is an example of a problem I am having when inserting records. I have a table called Person with a primary key called person_id. In SQL Server person_id is set up as an identify column. Here is the query object setup:
Code: Select all
SQL: SELECT * FROM person
SQLInsert: INSERT INTO person (person_id, name) VALUES (:PERSON_ID, :NAME)
SQLRefresh: WHERE person_id = :PERSON_ID
KeyFields = person_id
Options.RefreshOptions = roAfterInsert
Options.ReturnParams = True
Options.RequiredFields = False
Code: Select all
SpecificOptions.Oracle.KeySequence = person_seq
But connected SQL Server, when posting an inserted record, I get an error that says "cannot insert explicit value for identity column in table person when identity_insert is set to OFF".
Is there a way to insert into a table with an identity column in SQL Server so that the UniDac query object behaves the same as the Oracle insertion (refreshing after insert) without needing to change the queries?