Skip to Main Content

SQL & PL/SQL

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!

How to handle subquery in IF statement

851804Nov 11 2011 — edited Nov 14 2011
My original query is as follows:

IF rec.desp_ctr IN ('067') THEN
ln_qty := rec.prt_ord;
ELSIF rec.desp_ctr IN ('040','041','043') THEN
ln_qty := rec.qty;
END IF;

I need to modify the query and make it generic so as to handle more values. Something like-

IF rec.desp_ctr IN ('067') THEN
ln_qty := rec.prt_ord;
ELSIF rec.desp_ctr IN (SELECT DISTINCT(T1.RP_CD_PLANT) FROM V_RECEIVING_PLANT t1
WHERE T1.RP_CD_COMPANY = '1000'
AND T1.RP_CD_STATUS = 'A') THEN
ln_qty := rec.qty;
END IF;

The above returns an error saying that subquery is not allowed in this context. How else can I make my code generic so as to handle all records coming from V_RECEIVING_PLANT.

URGENT. Please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2011
Added on Nov 11 2011
6 comments
8,582 views