db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rcolmegna@tiscali.it" <rcolme...@tiscali.it>
Subject update generated-key before insert
Date Sun, 01 Aug 2010 07:30:21 GMT
hi,

I need to determinate the value of an auto-generated PK before the 
INSERT statement. I'm  trying to use
this SQLs:

1) LOCK TABLE sys.
columns FOR EXCLUSIVE READ
2) SELECT referenceid,
autoincrementvalue+autoincrementinc FROM sys.syscolumns AS sc INNER 
JOIN sys.systables AS st ON sc.referenceid=st.tableid WHERE 
tablename='EMAIL2FOLDER' AND columnname='ID';
3) UPDATE sys.syscolumns 
SET autoincrementvalue=autoincrementvalue+autoincrementinc WHERE 
tableid='f91a0030-0129-e07e-88ec-0000016e72a0' AND idColumnName='ID';

4) use autoinc value, from step-4 select, in my INSERT on the 
destination table

but I obtain an error due to the insufficient 
permission of the connected user (derby is used in embedded mode)
for 
the statement 1 and 3.

Is there any way to escale privileges or to 
create a special permission user-function?

TIA



Risparmia con Tutto Incluso Light: telefono + adsl 8 mega a soli 19,95 € al mese per un
anno!

SCONTO DI 120 EURO! 

L’offerta è valida solo se attivi entro il 29/07/10

http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso_light/?WT.mc_id=01fw

Mime
View raw message