Subject RE: [firebird-support] String with added string-variable
Author Svein Erling Tysvær
>Hello,
>
>I have test it now.
>
>stmtxt = 'select 1 from rdb$database where exists(SELECT *
>FROM RDB$RELATION_FIELDS
>WHERE RDB$RELATION_NAME = T_DT
> and RDB$FIELD_NAME = ''''' || fname || '''''';
>
>execute statement stmtxt into :idexists;
>
>The stmtxt is '..._Name = '''COLUMNAME'''' and I get an SQL-Error. The statement-text should be '..._Name = 'COLUMNNAME''.

Still not enough apostrophes (I needed six apostrophes when I did my test, but I only used apostrophes around a constant and didn't use any concatenation so you need more than me). Try

stmtxt = 'select 1 from rdb$database where exists(SELECT *
FROM RDB$RELATION_FIELDS
WHERE RDB$RELATION_NAME = T_DT
and RDB$FIELD_NAME = ''''''' || fname || '''''''';

(so seven apostrophes before fname and eight after to get the six apostrophes that I successfully used)

HTH,
Set