No question at this time
DBA Top 10
1 B. Vroman 14600
2 M. Cadot 11000
3 J. Schnackenberg 8200
4 T. Boles 7950
5 A. Kavsek 6200
6 M. Hidayathullah ... 2200
7 G. Lambregts 1100
8 T. P 1000
9 P. Wisse 900
10 B. Derous 500
10 . Lauri 500
10 R. Pattyn 500
About
DBA-Village
The DBA-Village forum
Forum as RSS
as RSS feed
Site Statistics
Ever registered users48286
Total active users1591
Act. users last 24h3
Act. users last hour0
Registered user hits last week242
Registered user hits last month1121
Go up

getting a pdb in a shell script
Next thread: ORA-3113 in Select with order by
Prev thread: RMAN not deleting expired/obsolete backup sets

Message Score Author Date
Hi Guys I am trying to get a pdb name from the ...... Tso P Oct 30, 2018, 09:51
Hi Tso, what "session altered" are you talking ...... Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts Ales Kavsek Oct 30, 2018, 13:22
Thanks Ales Below are the results from the scri...... Tso P Oct 30, 2018, 13:45
Hi Tso, I suspect that you have an "ALTER SESSI...... Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts Gareth Graham Oct 30, 2018, 13:53
You already have the current pdb you are in usin...... Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts Michel Cadot Oct 30, 2018, 14:53
Tso, Let us try a little different approach. ...... Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts Tim Boles Oct 30, 2018, 16:04
Thanks Guys @Tim, " Are you wanting a script th...... Tso P Oct 31, 2018, 11:02
Cool.... You might want to check out this page....... Score: 500 PtsScore: 500 PtsScore: 500 PtsScore: 500 PtsScore: 500 Pts Tim Boles Oct 31, 2018, 15:48
Thanks Tim... Tso P Nov 01, 2018, 11:30
I feel the need to mention, that exports using the...... Jan Schnackenberg Nov 06, 2018, 09:14

Follow up by mail Click here


Subject: getting a pdb in a shell script
Author: Tso P, South Africa
Date: Oct 30, 2018, 09:51, 19 days ago
Os info: solaris 10
Oracle info: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
Message: Hi Guys

I am trying to get a pdb name from the database to pass it as variable in a shell script.

How do get I get rid of the session altered statement in the results:

Like the script gets Session altered. PDBNAME instead of PDBNAME.

Below is my code:

FINDPDB=`sqlplus -s "/ as sysdba" <<EOF
set heading off feedback off verify off
select pdb_name from dba_pdbs where pdb_name != 'PDB\\$SEED';
exit
EOF
`

Please help...

Thanks in advance...
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Ales Kavsek, Slovenia
Date: Oct 30, 2018, 13:22, 19 days ago
Score:   Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts
Message: Hi Tso,

what "session altered" are you talking about??
I tried your "script" on Linux and it works just fine.
What you posted doesn't look like a complete script.
I would also suggest that instead of "explaining" what you're seeing, just copy/paste the result from your terminal.
Btw. I hope you realize that your script is logically flawed, because it assumes you have a single pdb....


Regards,
Ales
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Tso P, South Africa
Date: Oct 30, 2018, 13:45, 19 days ago
Message: Thanks Ales

Below are the results from the script...

Session altered. MYDBPDB1

Now I need to have MYDBPDB1 so that I can pass to the other code.

Thanks, for pointing out the logic flaw in the script.

Thanks
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Gareth Graham, United Kingdom
Date: Oct 30, 2018, 13:53, 19 days ago
Score:   Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts
Message: Hi Tso,

I suspect that you have an "ALTER SESSION" command in your ${ORACLE_HOME}/sqlplus/admin/glogin.sql file.
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Michel Cadot, France
Date: Oct 30, 2018, 14:53, 19 days ago
Score:   Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts
Message:
You already have the current pdb you are in using SYS_CONTEXT('USERENV','CON_NAME') wich is available for everyone and not only DBA.

Regards
Michel
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Tim Boles, United States
Date: Oct 30, 2018, 16:04, 19 days ago
Score:   Score: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 PtsScore: 200 Pts
Message: Tso,

Let us try a little different approach.

What type of script are you trying to actually build?

Are you wanting a script that runs something against every pluggable database within a CDB?

Are you wanting a script where you already know the name of the pluggable database and just want to pass it as a parameter?

Can you describe what you want this script to do?

We are kind of shooting in the dark here with our answers.

If you just want to suppress the "Session altered" message then taking what Gareth Graham pointed out.
I suspect you have an "ALTER SESSION" command in your ${ORACLE_HOME}/sqlplus/admin/glogin.sql file.


Look at the file and add at the beginning
set termout off
and at the end of it
set termout on

That should suppress the "ALTER SESSION" that is in that file.

Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Tso P, South Africa
Date: Oct 31, 2018, 11:02, 18 days ago
Message: Thanks Guys

@Tim, " Are you wanting a script that runs something against every pluggable database within a CDB? "

I am trying to export schemas from every pluggable database within a CDB.

I don't want to hard code the PDB name as I want the script to scan the CBD and get the pluggable database then export the schemas.

Thanks in advance...

Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Tim Boles, United States
Date: Oct 31, 2018, 15:48, 18 days ago
Score:   Score: 500 PtsScore: 500 PtsScore: 500 PtsScore: 500 PtsScore: 500 Pts
Message: Cool....

You might want to check out this page.....it has what I think is a pretty neat solution.

http://dbaharrison.blogspot.com/2015/01/datapump-out-from-all-pdbs-in-one-go.html
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Tso P, South Africa
Date: Nov 01, 2018, 11:30, 17 days ago
Message: Thanks Tim
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here

Subject: Re: getting a pdb in a shell script
Author: Jan Schnackenberg, Germany
Date: Nov 06, 2018, 09:14, 12 days ago
Message: I feel the need to mention, that exports using the SYS user might not be what you expect them to be.

So, to use the method by DBAHARRISON, you should call "catcon.pl" with the "-u" parameter to connect to SYSTEM or another suitable user with the required privileges.

See the leading paragraphs in the "Solution" section of

How To Connect As SYSDBA When Using Export Or Import (Doc ID 277237.1)

for details.

Apart from that: Genius!
Your rating?: This reply is Good Excellent
Goto: Reply - Top of page 
If you think this item violates copyrights, please click here