IF Condition

classic Classic list List threaded Threaded
4 messages Options
big
Reply | Threaded
Open this post in threaded view
|

IF Condition

big
Hi,
On 19c on AIX , IF condition in following bloc does not executed:

set serveroutput on
BEGIN
dbms_output.enable (1000000);
 dbms_output.put_line ( 'before ' || sys_context('USERENV','DB_NAME'));
IF $$ORACLE_SID='myCDB' THEN
execute immediate ( 'alter session set container="myPDB" ');
dbms_output.enable (1000000);
dbms_output.put_line ( 'condition ok ');
END IF;
dbms_output.enable (1000000);
 dbms_output.put_line ( 'after ' || sys_context('USERENV','DB_NAME'));
END;
/

After exection I have:
befor myCDB
after myCDB

What is wrong with my IF condition?

Thanks and regards.
Reply | Threaded
Open this post in threaded view
|

Re: IF Condition

ErmanArslansOracleBlog
Administrator
Did you check if you can see the pdb name using sys_context after executing -》 execute immediate ( 'alter session set container="myPDB" ');
Because we have a bug there.. that s why I m asking it.

Bug 22743059 - EBS MULTITENANT: SYS_CONTEXT('USERENV','DB_NAME') TO RETURN PDB NAME

Can you just get the value of a env variable using $$ there in plsql?
And why dont you use the sys_context there in the if condition as well?
big
Reply | Threaded
Open this post in threaded view
|

Re: IF Condition

big
Hi,
Thank you.

It does not execute:  execute immediate ( 'alter session set container="myPDB" ');  at all.

Then cannot see  the pdb name using sys_context after executing.

There should be something wrong with IF.

Regards.
Reply | Threaded
Open this post in threaded view
|

Re: IF Condition

ErmanArslansOracleBlog
Administrator
That $$oracle_sid is weird.
You run this script using sqlplus right? You got to read the value of env variables appropriately. Currently I m not able to check the script but this is not the way.. try passing that env variable's value to sqlplus and changr that IF line acoordingly.