Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 6 of 6 total |
How to retrieve an autoinc value after an INSERT |
Sun, May 25 2008 9:50 AM | Permanent Link |
"M.E." | After an ExecSQL to insert a record, it seems the query becomes inactive and
I'm not being able to retrieve the value assigned to the autoinc field. This is what I'm doing: With QueryTemp do begin SQL.Clear; SQL.Add('INSERT INTO "Items" (Cod)'); SQL.Add('VALUES (' + QuotedStr(Orc) + ')'); SQL.Add('COMMIT FLUSH'); ExecSQL; Id := FieldByName('Id').AsInteger; // ERROR HERE Close; end; What can I do to retrieve the Id value? Thanks Marcio |
Sun, May 25 2008 1:01 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Marcio,
<< After an ExecSQL to insert a record, it seems the query becomes inactive and I'm not being able to retrieve the value assigned to the autoinc field. This is what I'm doing: >> Use a parameterized INSERT like this: With QueryTemp do begin SQL.Clear; SQL.Add('INSERT INTO "Items" (ID, Cod)'); SQL.Add('VALUES (:ID, ' + QuotedStr(Orc) + ')'); SQL.Add('COMMIT FLUSH'); Prepare; ParamByName('ID').ParamType:=ptInputOutput; ExecSQL; Id := ParamByName('ID').AsInteger; end; -- Tim Young Elevate Software www.elevatesoft.com |
Sun, May 25 2008 1:30 PM | Permanent Link |
"M.E." | Thanks, Tim, but I'm getting an "Undeclared identifier: ParamType" error at
that line. Do I need to include some special unit at the Uses? Marcio "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> escreveu: > > Use a parameterized INSERT like this: (...) > ParamByName('ID').ParamType:=ptInputOutput; (...) |
Sun, May 25 2008 7:21 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Marcio,
<< Thanks, Tim, but I'm getting an "Undeclared identifier: ParamType" error at that line. Do I need to include some special unit at the Uses? >> You need the DB unit in the USES clause in addition to the edbcomps unit. -- Tim Young Elevate Software www.elevatesoft.com |
Sun, May 25 2008 8:48 PM | Permanent Link |
"M.E." | I forgot to say I am using Dbisam 4, not EDB.
DB and DBIsamTb units are already there. Marcio "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> escreveu: > > You need the DB unit in the USES clause in addition to the edbcomps unit. > |
Sun, May 25 2008 9:39 PM | Permanent Link |
"M.E." | Tim, thanks anyway, I found a workaround.
M. "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> escreveu: > You need the DB unit in the USES clause in addition to the edbcomps unit. |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |