Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Posts
    8

    Unanswered: 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!!

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    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.

  3. #3
    Join Date
    Jan 2012
    Posts
    8
    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

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    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.

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >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.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •