[Lazarus] Returning value from a Firebird (embedded) generator into Lazarus code
brian
brian at meadows.pair.com
Sat Apr 25 16:55:01 CEST 2015
On Sat, 25 Apr 2015 16:18:18 +0200 (CEST), you wrote:
>
>
>On Sat, 25 Apr 2015, brian wrote:
>
>>
>> Hi folks,
>>
>> Can someone please give me a hint with this problem. I'm new to
>> Firebird, but I needed a database which could be used in embedded
>> fashion, and seemed to have a choice of one under Linux.
>>
>> What I need to do is to return a value generated by a Firebird
>> generator into my Pascal code. Doing it what seemed to me to be the
>> obvious way returns zero rows, do I need to update an interim table
>> and then query that table? Or is there some other method which I've
>> missed?
>
>Do a
>
>SELECT GEN_ID(YOUR_GENERATOR,1) AS THEVALUE FROM RDB$DATABASE
>
>in a TSQLQuery instance. Then call "Open" and you can get the value.
>
>Something like:
>
>With TSQLQuery.Create(Nil) do
> try
> Database:=MyDatabase;
> SQL.Text:='SELECT GEN_ID(YOUR_GENERATOR,1) AS THEVALUE FROM RDB$DATABASE';
> Open;
> MyGenValue:=Fields[0].AsLargeInt;
> Finally
> Free;
> end;
>
>Michael.
Ahh.. OK, I knew it was something obvious. Thanks, Michael. I guess
I've forgotten more of my (Oracle) SQL than I thought. I see what I've
been doing wrong.
Brian.
More information about the Lazarus
mailing list