Subject Re: [firebird-support] Problem with quotes
Author Helen Borrie
At 04:03 PM 10/10/2005 +0200, you wrote:
>I would like to make procedure that return value form generator.
>Name of generator i send to procedure like parameter.
>If that generator does not exists procedure will make them.
>
>Code of procedure:

Life is just not that hard!!! Recode it like this:

CREATE PROCEDURE PROC_NOVA_SIFRA_GEN(GEN VARCHAR(31)) /* not varchar(50) */
RETURNS (SIF BIGINT)
AS
declare variable gname varchar(31) = ''; /* initialize as empty string */
DECLARE VARIABLE SQL1 VARCHAR(80);
begin
/* Is generator exist? */
select rdb$generator_name from rdb$generators
where rdb$generator_name = :GEN
INTO :gname;

if (gname <> GEN) then
begin
sql1 = 'create generator '|| :GEN;
execute statement sql1;
end
sql1 = 'select gen_id (' || GEN || ',1) from rdb$database';
execute statement sql1 into :SIF;
suspend;
end


./heLen