Hi, Gurus,
I am using apex.oralce.com, 22.1
In a region of cards, I use "PL/SQL Function Body returning SQL Query", here is the code:
DECLARE
mychoice VARCHAR2(1);
mysql VARCHAR2(2000);
BEGIN
mysql := 'SELECT ID, PREFERENCE, CITY||'', ''||STATE AS PLACE FROM SAMPLE_USER';
SELECT PREFERENCE INTO mychoice FROM SAMPLE_USER WHERE ID = v('USER_ID');
IF mychoice IN (1,2) THEN
mysql := 'SELECT ID, PREFERENCE, CITY||'', ''||STATE AS PLACE FROM SAMPLE_USER
WHERE PREFERENCE='||mychoice;
return (mysql);
END;
As you can see, if Preference in 1 or 2, add a "where clause", anything other than 1 or 2, no "where clause" necessary, but I got "no data found", if I change v('USER_ID') to a number that exists, validation passes.
I did research and tried various things, none works, please advise, I really appreciate it!