If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Change user in procedure to execute DML

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-12, 09:34
shein shein is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
Change user in procedure to execute DML

Hello guys, I'm trying to build a procedure very simple.
For "information security policies" beyond me i need to run a procedure that creates a new table with an user wich doesn't have creation permissions. Inside the procedure i need to log as owner(wich has permissions) and execute the create statement. I know this is kind of ridiculous and there are more effective ways, but it's the way the corporate do this things.
So basically, inside procedure: log as userOwner and Create Table (the table name is passed as parameter of the procedure)

I'm having problems to find some code or references to do the user change inside a procedure. Can anyone help me with this?
Thankss!!
Reply With Quote
  #2 (permalink)  
Old 02-07-12, 09:44
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,222
check out DBMS_SQL. It will allow you do login separately and execute sql commands.
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
  #3 (permalink)  
Old 02-07-12, 10:10
shein shein is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
Thanks for the response. I'm looking the package, but still don't find how to login with dbms_sql inside the procedure.
I'm thinking i should something like an alter session set current_schema=owner;
create table (...); But don't know if this will work
Reply With Quote
  #4 (permalink)  
Old 02-08-12, 14:48
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,222
Sorry, I was wrong. You can do it using exec_sql, but thats a form application.
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
  #5 (permalink)  
Old 02-08-12, 14:54
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
>i need to run a procedure that creates a new table
It is unwise to CREATE TABLE from any procedure.
Procedures are designed & meant to be run multiple times.
Any procedure that include CREATE TABLE devolves to a run once procedure.
Objects should be created via static SQL that gets runs once prior application version upgrade.
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On