Nevermind. I used: OPEN test FOR EXECUTE 'SELECT a, b, c FROM tbl WHERE d IN ' values;
Nik wrote: > I have a dynamic set of clauses that I would like to use in the cursor. > Is there a way to achieve this using the "IN" clause and a string, or > multiple "OR" clauses coupled with strings. > > This doesn't work, but it's an example of what I'm trying to do. > > ----------------------------------------- > DECLARE > test refcursor; > values varchar; > > BEGIN > -- This will be dynamically generated > values := '(1, 2, 3)'; > > OPEN test FOR SELECT a, b, c FROM tbl WHERE d IN values; > CLOSE test; > > END; > ----------------------------------------- > > or > > ----------------------------------------- > DECLARE > test refcursor; > values varchar; > > BEGIN > -- This will be dynamically generated > values := '(d=1 OR d=2 OR d=3)'; > > OPEN test FOR SELECT a, b, c FROM tbl WHERE values; > CLOSE test; > > END; > ----------------------------------------- ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match