thanks
Khalid, June 05, 2008 - 1:51 am UTC
Thanks a lot for your reply. But I'm already connected and the objective is changing the connection during the pl/sql code.
June 05, 2008 - 9:43 am UTC
you cannot, that would be like changing brains in the middle of a thought. Think about this please.
where is plsql running?
In the database
how did it get running?
a client connected to the database and ran it
what would happen if the connection was terminated?
plsql would be killed
for plsql to access another database, you use a DATABASE LINK and perform a distributed operation.
Just an idea
Martin Vajsar, June 05, 2008 - 4:18 am UTC
You state that you're already connected to the DB, so I assume that you wouldn't be tryting to connect to a different database. Maybe you could try to use the command
execute immediate 'alter session set current_schema=<i>scott</i>';
(You would need to use execute immediate for the DDL commands you have in the script anyway.)
This allows you to set another schema as "default", that is unqualified names of tables and other objects will be resolved in the schema you set. Of course you would still need the privileges to DML and even DDL commands in that schema, so it seems to me that you're trying to do something weird. Besides, wanting to set another schema in PL/SQL block in the middle of processing something looks pretty suspicious.
I'm writing this because I myself didn't know and missed the "alter session set current_schema" command really badly after turning to Oracle from MS SQL server for quite a long time.
WHAT?!?!
Duke Ganote, June 05, 2008 - 10:12 am UTC
@Khalid: What are you trying to do? Are you trying to copy data from one database into another and create tables? I can't tell from your example; it doesn't make sense to me.
I'm sure there's a solution, but I'm totally missing *what* you're trying to achieve.