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.

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to