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!

"ORA-01403: no data found" for "PL/SQL Function Body returning SQL Query", Apex 22.1

Larry HAug 15 2022 — edited Aug 15 2022

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!

Comments
Post Details
Added on Aug 15 2022
7 comments
1,157 views