On Mon, 7 Mar 2011, Koenraad Lelong wrote:

Hi,

I have a stored-procedure in Firebird, to generate a primary key :
CREATE PROCEDURE GEN_STA_NR
RETURNS (
   STA_NR Integer )
AS
begin
STA_NR=gen_id(StaffelNr_GEN, 1);
end^

How do I get the result ?
I made a query with sqldb :
execute procedure GEN_STA_NR returning_values :STA_NR
Then I executed that, but that gave an error. After googleing, I
modified the query to :
execute procedure GEN_STA_NR returning_values (:STA_NR)
Still gave an error when executing the query.

Just do a

  SELECT STA_NR FROM GEN_STA_NR;

But for getting the next value of a generator you don't need a stored procedure.
Just do a

  SELECT gen_id(StaffelNr_GEN, 1) AS THEID FROM RDB$DATABASE;

Since RDB$DATABASE is guaranteed to have 1 record, this always returns 1
record with the next value of your generator. I've been doing this since
years.

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to