Skip to main content
Participant
Jan 31, 2009 8:54 AM UTC
Question

Problem with INSERT

Hi

Using Flex to insert data through remoteobject. Using SAVE method generated from CFC Wizard.
Generated the following error:

Unable to invoke CFC - Error Executing Database Query.

Detail:
[Macromedia][SQLServer JDBC Driver][SQLServer]Cannot insert explicit value for identity column in table 'Transactions' when IDENTITY_INSERT is set to OFF.

Strange thing is that I dont see this problem with another sample application. I compared with that application (even the sql statements used to generate the database table) and everything looks similar so I can't understand why I have this error in my application.

Any help would be appreciated.
This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Feb 3, 2009 4:50 AM UTC
Sounds like you are inserting to a database table with an identity column. Identity columns increment the record set as they are inserted to the table (ie, 1,2,3,4,...) You cannnot explicitly insert into this column, so instead of

insert into myTable (id, value) values (5, 'my text')....

you would do

insert into myTable (value) values ('my text')

, if the identity column is "id".

Alternately, you can do an identity insert it the "id" value does not exist. You would first need to set identity inserts on you table to "ON" in your SQL statement before doing the INSERT.

set identity_insert myTable ON
go
insert into mytable (id, value) values (6, 'my text')
go
set identity_insert myTable OFF

That may not be the exact syntax for the indentity statement... But the id = 6 must not already exist in table or it will fail anyway.

A use of this may be at some point you deleted a record with id = 6, and want to reinsert it, but the next identity value for id is 10, lets say.... so if you do a regular insert to the table your next id is 10, if you set your identity insert to ON before doing the insert, you can explicitly set the id to "6", and insert the old record.
Translate
Inspiring
Jan 31, 2009 3:14 PM UTC
> Any help would be appreciated.

> Cannot insert explicit value for
> identity column in table 'Transactions' when IDENTITY_INSERT is set to OFF.

Well: what does the error message say is going wrong?

--
Adam
Translate