Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

q notation problem in function body returning SQL Query

wucis3 days ago

Using Apex 21.2 and oracledb 21c xe , an IG region takes as source a 'function body returning SQL Query' using the q notation.
The code looks like

DECLARE

l_sql VARCHAR2(4000);
l_search VARCHAR2(400) DEFAULT '305,306' ;

BEGIN

--l_search := ''||:P153_GRP_LIST ||'';

l_search := '78,79' ;
--l_search := :P153_GRP ;

--PRINT2( 'l_search: : '||l_search ) ;

l_sql := q'~
select ROWID,
MOT_TOPGRP_ID,
GRUPPE,
ART_BESTAND
from MOT_TOPGRP

WHERE 1=1
AND GRUPPE IN ( ~' || l_search || q'~ )
~';

--IF ( 1 = 1 ) THEN
--l_sql := l_sql || q'~ AND GRUPPE IN ( ~' || :P153_GRP || q'~ ) ORDER BY 1 ~' ;
--END IF;

RETURN ( l_sql ) ;

END;

P153_GRP_LIST is a text-item on the page containing e.g. 407,408
means a list of GRUPPE numbers separated with comma in preparation for the IN ( ... ) part.
If l_search as a predefined string is used in the AND GRUPPE IN ( ... ) part it works,

but I did not succeed using the :P153_GRP_LIST for the enumeration part, the code gives a parsing SQL error

How would the correct syntax be when using :P153_GRP_LIST ?

This post has been answered by Anton Scheffer-Oracle on Mar 28 2025
Jump to Answer

Comments

Processing

Post Details

Added 3 days ago
7 comments
55 views