Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 4 of 4 total |
Output parameter in Query, not script |
Sun, Feb 7 2010 11:45 PM | Permanent Link |
Peter | Hello
I would like to use an output parametr to obtain the seed value used in the current query's operation. By that I mean, the first field in the table is a an IDENTITY field, generated by default, so that field is no longer in the INSERT statement. However, I would like to get the value of the IDENTITY field as part of the process, as sometimes I need to use that value to create a detail table record. The existing code looks like this... AQuery.SQL.Add('INSERT INTO "Drafts" (Client_ID, LastSaved,'+ ' Description, LetterType) VALUES (:Client_ID, :LastSaved, :Description, :LetterType)'); AQuery.ParamByName('Client_ID').AsInteger := iClientID; AQuery.ParamByName('LastSaved').AsDateTime := Now; AQuery.ParamByName('LetterType').AsInteger := iLetterType; AQuery.ParamByName('Description').AsString := sFileName; AQuery.Prepare; AQuery.ExecSQL; ...which works just fine, as do numerous similar inserts. What I would like to know is how to use the Output parameter to read the value that was inserted into the first (generated) field, which is named DraftID. How can I define that parameter then read it? Regards & TIA Peter |
Mon, Feb 8 2010 2:48 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
Sound like you're asking for last autoinc. In which case search in the elevatedb.sql newsgroup for the thread DBISAM -> EDB: LASTAUTOINC Roy Lambert [Team Elevate] |
Mon, Feb 8 2010 2:58 AM | Permanent Link |
Uli Becker | Peter,
> ..which works just fine, as do numerous similar inserts. What I would like to know is how to use the Output parameter to read the value that was > inserted into the first (generated) field, which is named DraftID. > > How can I define that parameter then read it? with AQuery do begin sql.add('insert into Drafts (DraftsID,CientID) values (:ReturnIdentity,:FClientID)'); ParamByName('FClientID').asInteger := iClientID; ParamByName('ReturnIdentity').ParamType := ptInputOutput; ExecSQL; WantedID := ParamByName('ReturnIdentity').asInteger; end; Regards Uli |
Mon, Feb 8 2010 4:52 AM | Permanent Link |
Peter | Uli & Roy
Thank you very much, I see how it works now. Regards Peter |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |