Escape Sequence!

Escape Sequence!

 

  

LeavesHi All

I'm putting my SQL in a String through which I'll PREPARE the Statement and create a Cursor for that. The problem I'm facing is the my SQL contains ' (Single Quotes) in between which causes the unmatched quotes.

Sample SQL :

DECLARE temp_sql VARCHAR(100);
DECLARE stmt STATEMENT;
DECLARE temp_cur CURSOR WITH RETURN TO CALLER FOR stmt

BEGIN
SET temp_sql = 'SELECT temp FROM temp_tab WHERE temp_fn(t, 'a') = 2';
END

PREPARE stmt FROM temp_sql;
OPEN temp_cur;

It gives error the "a is not a recognised procedure of function". Note in the SELECT Statement there are four ' which are matched as 1-2 and 3-4 with "a" left stranded in between. How can I overcome this.

Kindly Guide

Ashish

DB2 & UDB email list listserv db2-l LazyDBA home page