Subject RE: [firebird-support] Generator in SP
Author Thomas Steinmaurer
> The following Generator returns NULL when I use following SQL
>
> SELECT NEW_EVRAKNO FROM GPR_MALZEMEHAREKET_EVRAKNO
>
>
> CREATE PROCEDURE GPR_MALZEMEHAREKET_EVRAKNO
> RETURNS (
> NEW_EVRAKNO VARCHAR (20))
> AS
> BEGIN
> NEW_EVRAKNO = 'EN' || GEN_ID(malzemehareket_evrakno, 1);
> END
>
> But, If I use Trigger there is no problem,
>
> Do you know? What is the reason?

How do you use/call the stored procedure?

With:

EXECUTE PROCEDURE GPR_MALZEMEHAREKET_EVRAKNO ...

or with:

SELECT * FROM GPR_MALZEMEHAREKET_EVRAKNO

?

If it is the latter, then you need a SUSPEND after the
NEW_EVRAKNO assignment.

CREATE PROCEDURE GPR_MALZEMEHAREKET_EVRAKNO
RETURNS (
NEW_EVRAKNO VARCHAR (20))
AS
BEGIN
NEW_EVRAKNO = 'EN' || GEN_ID(malzemehareket_evrakno, 1);
SUSPEND;
END


As said, the usage of SUSPEND depends on how you use/call
the stored procedure.


HTH,
Thomas