PDA

Click to See Complete Forum and Search --> : ADO.NEt Get column value after update without a select statement


RSJIG
Oct 3rd, 2005, 11:36 AM
I need to perform an update of a table row where there are 2 field, a pk and a counter field. I need to update the counter field to +=1 and then get the value it was updated to without performing a select.

Is this possible?

Thanks.

vincentg
Oct 3rd, 2005, 11:39 AM
fetching the new value for your pk?

Try using @@IDENTITY after insert

INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @@IDENTITY AS 'Identity'

vincentg
Oct 3rd, 2005, 11:46 AM
I am not sure if it is possible ....

SELECT ( INSERT) <---- one line...

RSJIG
Oct 3rd, 2005, 11:48 AM
Not microsoft DB,
Sorry I should have stated that it is an Informix Database. And I can get the PK back, but the problem is that the the is only one PK value and I am updating the counter immediately and want to ensure that I get back the updated value as by the time i do a select it could have changed.

Thanks for the reply

RSJIG
Oct 3rd, 2005, 11:51 AM
Thanks
But SELECT ( INSERT) <---- one line...
does not work. Just tried.

Thanks for the suggestion