Subject Re: [firebird-support] How I can know wich is the value generated?
Author Gordon Niessen
On 3/10/2011 12:04 PM, W O wrote:
>
> Hello everybody
>
> I have a trigger like this:
>
> SET TERM ^ ;
>
> CREATE TRIGGER MOVIM_BI FOR MOVIMCAB
> ACTIVE BEFORE INSERT
> POSITION 0
> AS
> BEGIN
> IF (NEW.MVC_IDENTI IS NULL OR NEW.MVC_IDENTI = 0) THEN
> NEW.MVC_IDENTI = GEN_ID(GEN_MOVIM, 1);
> END^
>
> SET TERM ; ^
>
> and it works fine, no problem. Besides it, I have a Stored Procedure like
> this:
>
> SET TERM ^ ;
>
> CREATE PROCEDURE SAVE_HEADER (
> IDENTI TYPE OF D_IDENTIFICATOR,
> AS
> BEGIN
> UPDATE OR INSERT INTO MOVIMCAB
> (MVC_IDENTI)
> VALUES (:IDENTI);
> END^
>
> SET TERM ; ^
>
> And it works fine, too. Now, my question is: How I can know which is the
> value of the column MVC_IDENTI? Is it 5, is it 12, is it 26? I need that
> value to be returned to my application because it will be used later in my
> child table. The same value that have MVC_IDENTI I need to store in the
> child table.
>
> Thanks in advance.
>
> Walter.
>
> .
>
>
RETURNS (NEWID TYPE OF D_IDENTIFICATOR)

or more precisely:

CREATE PROCEDURE SAVE_HEADER (
IDENTI TYPE OF D_IDENTIFICATOR)
RETURNS (NEWID TYPE OF D_IDENTIFICATOR)
AS
BEGIN
if (IDENTI IS NULL OR NEW.MVC_IDENTI = 0) then
NEWID = GEN_ID(GEN_MOVIM, 1);
else
NEWID = IDENTI;
UPDATE OR INSERT INTO MOVIMCAB
(MVC_IDENTI)
VALUES (:NEWID );
END

--
Thanks,

Gordon



[Non-text portions of this message have been removed]