Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread SELECT @@IDENTITY
Wed, Aug 18 2010 7:09 AMPermanent Link

Sergey A. Kolotov

How I can use SELECT @@IDENTITY in ElevateDB?
How I can get ID of last added record into table?
Wed, Aug 18 2010 10:42 AMPermanent Link

Sergey A. Kolotov

How I can get ID after insert when ID parameter is not present in SQL statement?

 EDBQuery1.SQL.Clear;
 EDBQuery1.SQL.Add('INSERT INTO Table1 (Text1)');
 EDBQuery1.SQL.Add('VALUES(:Text1)');
 EDBQuery1.ExecSQL;
 ShowMessage(EDBQuery1.ParamByName('ID').AsString);

It is table creation statement:
CREATE TABLE "Table1"
("ID" INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1) PRIMARY KEY,
"Text1" VARCHAR(25) COLLATE "UNI")
Wed, Aug 18 2010 11:38 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sergey


Search for this subject

DBISAM -> EDB: LASTAUTOINC

in this newsgroup. I think the answer is there.

Roy Lambert [Team Elevate]



Fri, Aug 20 2010 11:19 AMPermanent Link

Sergey A. Kolotov

There is a error "ElevateDB Error #700 An error was found in the statement at line 1 and column 8 (ElevateDB Error #401 The function LASTAUTOINC does not exist in the schema Default)" at SQL statement "select LASTAUTOINC("Table1") from Table1".
Fri, Aug 20 2010 12:06 PMPermanent Link

Uli Becker

LastAutoInc does not exist in EDB.
Sat, Aug 21 2010 3:06 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sergey


MAX(columnname)

Roy Lambert
Mon, Aug 23 2010 7:32 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sergey,

<< How I can get ID after insert when ID parameter is not present in SQL
statement? >>

What you want is this:

 EDBQuery1.SQL.Clear;
 EDBQuery1.SQL.Add('INSERT INTO Table1 (ID, Text1)');
 EDBQuery1.SQL.Add('VALUES(:ID, :Text1)');
 EDBQuery1.Prepare;
 EDBQuery1.ParamByName('Text1').AsString:='Some text';
 EDBQuery1.ExecSQL;
 ShowMessage(EDBQuery1.ParamByName('ID').AsString);

INSERT statements automatically set all parameters to IN/OUT so that any
generated/computed column values (including IDENTITY columns) can be
retrieved via the same parameters after the INSERT is executed.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image