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 call Dynamic SQL in IF condition

User_B9XGOAug 17 2017 — edited Aug 18 2017

Hi all,

I have lot of conditions in the IF statement.So I wanted to try something new and not sure if there is a possibility for such approach.

Say my IF condition is something like the below(just an example):

IF lv_sal > 1000  AND lv_deptno = 10

THEN

OPEN C1

..

..

lv_sal , lv_deptno ,lv_hiredate  are the procedure parameters

New approach:

lv_query : =        'lv_sal >'

                          ||''''

                          ||'1000'

                          ||''''

                          ||'  AND lv_deptno = '

                          ||''''

                          ||'10'

                          ||'''';

IF || lv_query

THEN

OPEN C1

..

..

when I tried IF || lv_query it errors

Is there any such approach ?

Thanks,

Veronica

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2017
Added on Aug 17 2017
8 comments
1,716 views