07-20-2007 4:47 PM
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.
07-20-2007 5:00 PM
Hi
TABLES: EKKO.
DATA L_WHERECOND TYPE TEXT50 OCCURS 0 WITH HEADER LINE.
CONCATENATE 'EBELN' 'EQ' '4500016938'
INTO L_WHERECOND SEPARATED BY SPACE.
APPEND L_WHERECOND.
SELECT SINGLE * FROM EKKO
WHERE (L_WHERECOND).
WRITE: SY-SUBRC.
WRITE: EKKO-EBELN, ekko-ebeln.
thanks
Mahesh
07-20-2007 5:04 PM
Hi,
Please try with order by clause in select statement and also use descending
select * from (p_table)
into corresponding fields of table <ptab>
up to p_rows rows
order by <fieldname> descending.
aRs
07-20-2007 5:39 PM
Hello Jerry,
I guess
SELECT
(p_v_sqlobj_select) "<-------this is not possible.
INTO CORRESPONDING FIELDS OF TABLE <matrix>
FROM (p_v_sqlobj_from) <-----this is possible
WHERE (p_v_sqlobj_where). <-----this is possible internal table of field 72 char .
Regards,
A.Singh