Subject Problem with quotes
Author Miki Avramovic
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:

CREATE PROCEDURE PROC_NOVA_SIFRA_GEN(GEN VARCHAR(50))
RETURNS (SIF BIGINT)
AS
DECLARE VARIABLE SQL1 VARCHAR(1024);
DECLARE VARIABLE BR INTEGER;
begin
/* Is generator exist? */

SQL1 = ' select ' ||
' count(RDB$GENERATOR_NAME) ' ||
' from RDB$GENERATORS ' ||
' where RDB$GENERATOR_NAME=''' || :GEN || '''';

execute statement SQL1
into :BR;

if (BR is null) then
BR = 0;

/* if it is not exists then create new generator */
if (br = 0) then
begin
SQL1 = 'CREATE GENERATOR ' || :GEN;
execute statement SQL1;
end

/* Get value from new or old generator */
SQL1 = 'select GEN_ID('|| :GEN ||',1) from RDB$DATABASE';
execute statement SQL1
into :SIF;

suspend;
end


While i trace procedure i see that i have problem with quote in
statement:
SQL1 = ' select ' ||
' count(RDB$GENERATOR_NAME) ' ||
' from RDB$GENERATORS ' ||
' where RDB$GENERATOR_NAME=''' || :GEN || '''';

I would like to make following SQL in execute statement block:
select
count(RDB$GENERATOR_NAME)
from RDB$GENERATORS
where RDB$GENERATOR_NAME='SIF_GEN'
into :BR;

I do not know how to make single quote outside variable :GEN

Best Regards to All!
Mik A