Skip to Content
0
Former Member
Jul 20, 2007 at 03:47 PM

Dynamic SQL and Sub Query

229 Views

I want need to use dynamic SQL, and include a subquery in the where clause. However, I am getting a syntax error.

I have code that looks like this.

    SELECT (p_v_sqlobj_select)
        INTO CORRESPONDING FIELDS OF TABLE <matrix>
      FROM (p_v_sqlobj_from)
      WHERE (p_v_sqlobj_where).

and I pass it the following bold-faced SQL where clause (please ignore whether the statement makes sense and is the best way to do it - this is just to illustrate). However, it returns an error.

select tcode from tstc where tcode in <b>( select min( tcode ) as min from tstc )</b>

Am I correct in concluding that I cannot pass complex statements, or have I just missed something?

Thanks for any help.