Your query should fail because you compare to "" instead of '' and there's no blank netween SAMPLE and 1.
Quote FLD_NM in your select, two single quotes result in one single quote, this should work:
SET Q1 = 'INSERT INTO DLWORK_DB01.TEMP1(COLUMNNAME) SELECT(''' || FLD_NM || ''') FROM '|| ' DLWORK_DB01.CLOSURE_CODE' ||
' WHERE ' || ' SUBSTR('||FLD_NM ||',1,1) = '''' SAMPLE 1' ;
You might also switch to TOP 1 or better EXISTS, which might provide better performance.
Dieter
Your query should fail because you compare to "" instead of '' and there's no blank netween SAMPLE and 1.
Quote FLD_NM in your select, two single quotes result in one single quote, this should work:
You might also switch to TOP 1 or better EXISTS, which might provide better performance.
Dieter