[Lazarus] Returning value from a Firebird (embedded) generator into Lazarus code
Michael Van Canneyt
michael at freepascal.org
Sat Apr 25 16:18:18 CEST 2015
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.
More information about the Lazarus
mailing list