Executing procedures on others schemas

Hello there,
I have 2 schemas A and B, that have the same objects, but different data.
Being connected as user A, I have to launch a stored procedure F on the B schema; F updates a table X.
Is there a way to tell Oracle to execute the stored F on B.X table, instead of A.X?
Thanks a lot, Mark

Please see the following links. It may be of some help.
http://asktom.oracle.com/pls/ask/f?p=4950:8:246224226398584505::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1168835334321,
http://asktom.oracle.com/pls/ask/f?p=4950:8:246224226398584505::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:794626247590,

Similar Messages

  • Permisssion for executing procedure from different schema

    Hi ,
    I am executing following procedure in different package and, I am getting error. Following procedure and error:
    Procedrue:
    DECLARE
    l_tbl_timecard_info APPS.HXC_self_service_time_deposit.timecard_info;
    l_tbl_attributes_info APPS.HXC_self_service_time_deposit.app_attributes_info;
    l_tbl_messages APPS.HXC_self_service_time_deposit.message_table;
    l_new_timecard_id NUMBER;
    l_new_timecard_ovn NUMBER;
    l_time_building_block_id APPS.HXC_time_building_blocks.time_building_block_id%TYPE;
    begin
    --FND_GLOBAL.APPS_INITIALIZE( user_id => 12345,resp_id => 56789,resp_appl_id => 809 );
    APPS.HXC_timestore_deposit.create_time_entry ( p_measure=> 7, p_day => APPS.fnd_date.canonical_to_date ('2002/09/02'), p_resource_id=> 9389, -- Identifies a person on our DB, REPLACE WITH YOUR IDs
    p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id);
    end;
    Error:
    Error starting at line 1 in command:
    DECLARE
    l_tbl_timecard_info APPS.HXC_self_service_time_deposit.timecard_info;
    l_tbl_attributes_info APPS.HXC_self_service_time_deposit.app_attributes_info;
    l_tbl_messages APPS.HXC_self_service_time_deposit.message_table;
    l_new_timecard_id NUMBER;
    l_new_timecard_ovn NUMBER;
    l_time_building_block_id APPS.HXC_time_building_blocks.time_building_block_id%TYPE;
    begin
    --FND_GLOBAL.APPS_INITIALIZE( user_id => 12345,resp_id => 56789,resp_appl_id => 809 );
    APPS.HXC_timestore_deposit.create_time_entry ( p_measure=> 7, p_day => APPS.fnd_date.canonical_to_date ('2002/09/02'), p_resource_id=> 9389, -- Identifies a person on our DB, REPLACE WITH YOUR IDs
    p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id);
    end;
    Error report:
    ORA-00942: table or view does not exist
    ORA-06512: at "APPS.HXC_TIMESTORE_DEPOSIT_UTIL", line 1519
    ORA-06512: at "APPS.HXC_TIMESTORE_DEPOSIT_UTIL", line 1599
    ORA-06512: at "APPS.HXC_TIMESTORE_DEPOSIT", line 1233
    ORA-06512: at "APPS.HXC_TIMESTORE_DEPOSIT", line 1327
    ORA-06512: at line 10
    00942. 00000 - "table or view does not exist"
    *Cause:   
    *Action:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    The schema on which you are running this procedure do not have the access to the tables that you are referring in this procedure.

  • Grants needed for form on procedure in other schema

    Hi,
    I'm running Apex 4.1.0.00.32 and want to create a form on a procedure in a package.
    My package is not in the parsing schema.
    The wizard lets me select the schema of the package ("procedure owner") and lists package.procedure in the list.
    When I click next I get
    Error User APEXDEV has no privileges on the RIS schema.
    Contact your application administrator.
    A strange thing here is that APEXDEV is the Apex user I'm logged in as in Apex. There is no schema called that...
    RIS is the schema owning the package, so that's correct.
    I have granted execute on the package to APEXRUN (the parsing schema of the workspace).
    I tried to granet execute to both APEX_PUBLIC_USER and PUBLIC but got the same error.
    A public synonym had no effect either.
    Does anyone know what grants are needed?
    Kind regards
    Tomas

    Well, OOW is over by now...

  • How to get the own schema data while calling the other schema's Procedure

    Hello Experts,
    I'm Sanjit, new to OTN forum.
    I'm using Oracle 10g 10.1.0.2.0 database. Another user Sush has created one procedure proc_1 like
    create or replace procedure proc_1
    as
    v_total number;
    begin
    select sum(amt) into v_total from trans_master where dot
    between add_months(sysdate,-3) and sysdate;
    dbms_output.put_line('last three months total transactions is: '||v_total);
    end proc_1;
    He has the Trans_master table and having 280 records and I have the same Trans_master table with 430 records
    inserted in last 3 months. He has granted execute privileges on the procedure Proc_1 to me. When I call the procedure
    I cannot call it directly like my own schema procedures: Exec Proc1;
    I am calling like : Exec Sush.Proc1 to get the result. My issue is: when the procedure is called,
    it is accessing the data from the Sush schema Trans_master table with 280 records total, but I want
    the procedure to get the total amount of transaction of 430 records from my own Trans_master table.
    Please resolve my issue which would be a great help. And is there any way to call the procedure of other schema
    by not attaching the owner name of the object with it?
    Thanks
    Sanjit

    Pleast take a look at "Definer's rights and invoker's rights" in the following article:
    http://docs.oracle.com/cd/E11882_01/timesten.112/e21639/accesscntl.htm#BABDDCHC
    I guess you need to define a stored procedure with "invoker's rights".
    If this is what you are looking for will have to define it in the stored procedure that you are going to call.
    The syntax is as follows:
    create or replace procedure <yourprocedure> authid current_user ...
    ...or (the following is the default, you don't have to use the "authid definer" keywords):
    create or replace procedure <yourprocedure> authid definer ...
    ...hm

  • Dbma_scheduler job executing procedure that loops through all client schemas in the database rolls back transaction incase of exception

    Hi,
    Needed your inputs on approach to implement a job using dbms_scheduler.
    We have around 2000 schemas. Each schema has a package with 2 procedures.
    The requirement is to create a single job in SYS that would loop through each schema and run the procedures at a specific time ( once a day) and send email notification on success or failure.
    Job script:
    BEGIN
        dbms_scheduler.create_job( job_name=> 'LOAD_EACH_SCHEMA_AUDIT_DATA',
                                   job_type=>'PLSQL_BLOCK',
                                   job_action=>'BEGIN  sys.p_loadaudit;     
                                    END;',
                                   start_date=>systimestamp,
                                   repeat_interval=>'FREQ=MINUTELY;INTERVAL=1',
                                   number_of_arguments=>0,
                                   enabled=> true,
                                   comments=>'Job repeat interval is every 5 mins' );
                                   END;
    Note: for testing purpose i have set repeat interval to minutely.
    Procedure job will be executing:
    Procedure sys.p_loadaudit:
    CREATE OR REPLACE
    PROCEDURE p_loadaudit
    AS
        v_count          NUMBER:= 0;
        lv_error_message VARCHAR2(4000);
        vstmt            VARCHAR2(4000);
    BEGIN
        FOR i IN
        ( SELECT username FROM dba_users WHERE username LIKE 'ABCFIRM%'
        LOOP
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_coa; end;';
            EXECUTE immediate vstmt;
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_am; end;';
            EXECUTE immediate vstmt;
        END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
        lv_error_message := 'Error in procedure p_loadaudit: ' || SQLCODE || ' -ERROR- ' || SUBSTR(
        sqlerrm,1,300) || '*' || dbms_utility.format_error_backtrace;
        raise_application_error(-20002,lv_error_message);
    END p_loadaudit;
    Example of one schema: SCHEMA_01
    create or replace
    PACKAGE pkg_audit_info
    AS
    type cursortype
    IS
        ref
        CURSOR;
            PROCEDURE p_load_COA;
            PROCEDURE p_load_AM;
       END pkg_audit_info;
    create or replace
    PACKAGE body pkg_audit_info
    AS
    PROCEDURE p_load_COA
    AS
    BEGIN
    INSERT INTO TABLE1();
    EXCEPTION
    WHEN OTHERS THEN
        lv_error_message := 'Error in procedure pkg_audit_info.p_load_COA: ' || SQLCODE
        || ' -ERROR- ' || SUBSTR(SQLERRM,1,300) || '*' || dbms_utility.format_error_backtrace;
        RAISE_application_error(-20002,lv_error_message);
    END p_load_COA;
    PROCEDURE p_load_AM
    AS
    BEGIN
    INSERT INTO TABLE2();
    EXCEPTION
    WHEN OTHERS THEN
        lv_error_message := 'Error in procedure pkg_audit_info.p_load_AM: ' || SQLCODE ||
        ' -ERROR- ' || SUBSTR(SQLERRM,1,300) || '*' || dbms_utility.format_error_backtrace;
        RAISE_application_error(-20002,lv_error_message);
    END p_load_AM;
    END pkg_audit_info;
    Table1 and table1 exist in schema_01.
    All 2000 schemas have same package.procedures.
    Due to security reasons i have removed the actual code.
    I was able to execute the job successfully. However, when a schema procedure (SCHEMA_01.pkg_audit_info.p_load_COA) throws an exception, the job fails and all transaction is rolled back.
    Is there a way to loop through each schema and execute the related procedures. Even if exception happens, it should rollback only for that schema and continue the other schemas in the loop?
    Please let me know if there is a better way to achieve this. Is the way i am handling exceptions in the job/procedure correct?
    Thanks

    Hi,
    RAISE_APPLICATION_ERROR will cause the program to exit back to the caller, even if you place it in a block within the loop, so the RAISE or RAISE_APPLICATION_ERROR instruction should be placed in your "pkg_audit_info.p_load_AM" and "pkg_audit_info.p_load_coa" procedures. This way, you can use a block inside the loop and log the error.
    FOR i IN
        ( SELECT username FROM dba_users WHERE username LIKE 'ABCFIRM%'
        LOOP
           BEGIN
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_coa; end;';
            EXECUTE immediate vstmt;
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_am; end;';
            EXECUTE immediate vstmt;
    EXCEPTION
    WHEN OTHERS THEN  
        --> Log the error in a custom log table otherwise you will not know what happened for that schema: don't forget the username
    END;
    END LOOP;

  • Can a procedure select data from tables on other schemas?

    Can a procedure select data from tables on other schemas?
    If it is posible, which syntax should I use to identify the tables and schemas on the SELECT query?

    Yes , it is possible..unless the current user has the right privileges on others' db objects schema.
    Now , as regards the syntax....
    1) The more descriptive way is to use the format ... <owner_schema>.<obj_name>.
    2) If you have declared public synonyms of other schema's objects then you can refer to them as just <obj.name>.... but the <owner_schema>.<obj_name> is not wrong.
    3) If the db objects reside on another database you must have declared a db link.... then the syntax is <owner_schema>.<obj_name>@<db_link_name>.
    Regards,
    Simon

  • How to execute procedure in toad software

    hiii guy's i run my procedure on sql prompt and it run properly
    but when i tried this on toad i got an problem
    after compiling my procedure on toad
    when i write
    execute procedure_name(parameter1,parameter2);
    then i get an error i.e
    ORA-00900: invalid SQL statement
    can someone tell me how to execute procedure on toad
    thanks in adv...........

    how to execute procedure in toad softwareIn TOAD's schema browser you can go to the procedures tab - right click on the procedure in question and choose execute procedure - a window should pop up, where you can give optional parameters - the rest should be almost self explanatory ;)

  • Error using views from other schema

    Hello,
    i recently had problems using the execute immediate statement in Object Types.
    The SQL statement tried to select from some views which were owned by an other schema.
    Although we had public synonyms on these views and the same dynamic sql could be used out of a stored procedure the usage in the object type raised a "table or view does not exist exception".
    using the same views in the same schema where the object types belonged to, was ok.
    example:
    schema: scott
    view: my_view
    schema: dave
    sql: "select from scott.my.view ....."
    works well from a stored procedure, but nor if used in an object type
    create the view in schema "dave" an then
    sql: "select from my.view ....."
    works fine.
    So is someone aware of this behaviour?
    Is this a bug or a feature?
    regards
    peter

    Hello Geoff,
    here is the sample code.
    If the table my_table belongs to the same
    schema runningthe code the code runs with
    no exception.
    But if the table belongs to an other schema
    (lets say SCOTT),
    only having global synonyms and the rigths to
    select on it, the code will raise an exception "table or view does not exist"
    even if we use SCOTT.my_table in the
    select.
    create type query_o as object(
    dummy integer,
    static function get_query return
    varchar2;
    create or replace type body query_o as
    static function get_query return varchar2
    as
    query varchar2(4000) :=
    'select ' &#0124; &#0124;
    ' f.amount_month ' &#0124; &#0124;
    'into :r1 ' &#0124; &#0124;
    'from ' &#0124; &#0124;
    ' my_table f ' &#0124; &#0124;
    'where id=:p1 ';
    begin
    return query;
    end;
    end;
    create type consumer_o as object(
    amount_month number,
    member function find(p_id in integer)
    return consumer_o
    create type body consumer_o as
    member function find(p_id in integer)
    return consumer_o
    as
    l_amount number;
    begin
    execute immediate query_o.get_query()
    using out l_amount,
    in p_id;
    return consumer_o( l_amount );
    end;
    end;
    kind regards
    peetr

  • Error in Executing Procedure through DBLink

    Hi,
    I am facing some problems in executing a procedure through DBLink.
    I have two schema A and B in two different database.
    In schema A I am having one procedure X in package Y and my requirement is that I want to execute this procedure in schema B. So in schema B i have created one DBLink ABC and trying to execute procedure X using this DB link.
    begin
    A.Y.X@ABC;
    end;
    But I am getting below error:
    ORA-06550: line 2, column 1:
    PLS-00201: identifier 'A.Y.X@ABC' must be declared
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    Any help would be greatly appreciated!
    Thanks In Advance..
    Regards,
    Sachin Bansal

    Hi,
    Yes, I am connecting to user A of DB1 and in this user I am having procedure X in Package Y. My DBLink in Schema B of DB2 is pointing to user A of DB1.
    I have created DBLINK using below script:
    create public database link abc
    connect to A
    identified by A
    using '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX)(PORT=1521)))(CONNECT_DATA=(service_name=XXX)))';
    Above DBLInk is working fine..I am able to access all the table of schema A in schema B using this DBLink. But when I trying to execute any procedre of schema A in schema B then i am getting error.
    Regards,
    Sachin

  • Problem in compiling procedure from another schema

    Hi all
    I have got 2 schemas, say A and B.
    Schema A owns a procedure P which selects data from table T1 ( external table ) and updates table T2.
    i have granted Schema B
    1) read, write privilege on the directory that table T1 refrences.
    2) all on table T1
    3) all on table T2
    4) execute on P
    I have created public synonyms for T1, T2 and P ( same name ).
    Now when i try to compile procedure P from schema B I get error
    ORA-01031: insufficient privileges
    Where am i wrong?
    Please Help

    You'll need CREATE ANY PROCEDURE privilege for that.
    Is there any reason why you don't post the one thing on which you are asking about : the alter procedure statement?
    (apart from also not posting the version, which you always should include)
    Sybrand Bakker
    Senior Oracle DBA

  • Help with truncating a table using plsql procedure in different schema

    I have a plsql procedure in schema A that truncates a table that is given in as parameter.
    create or replace procedure truncate_table(schema, table_name)
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||schema||'.'||table_name;
    end;
    The above procedure has public execute grant.
    I need to truncate a table in schema B. I have a plsql procedure in schema B that calls the truncate_table procedure and passes in the schema B table name.
    Since the table is in schema B, should the delete grant on the table be given to user A or user B to truncate the table in schema B?
    Thanks in advance.

    Procedure created in schema A
    create or replace
    procedure truncate_table(l_schema varchar2, table_name varchar2) authid current_user
    as
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||l_schema||'.'||table_name;
    end;from schema B
    grant delete on table1 to Schema_A
    from schema A
    exec truncate_table('Schema_B','Table1');
    Hope this helps.
    Alvinder

  • Query in Stored Procedure accessing another schema

    Hi - this is going to sound kind of strange and even i can't come up with an explanation. My JDK 1.1.7 applet uses a type 4 JDBC thin driver (i think v 8.04.06) to access an Oracle 7.3.4 database. We also have a link with full grants and synonymns to another Oracle schema in an Oracle 8 database. Has never been a problem - we can access anything we need to through queries or stored procedures from either of these databases.
    So, i have a new stored procedure that needs to be called through JDBC that queries a table in the Oracle 8 database. For some reason, whenever i execute this stored procedure from java it hangs on this query and the instance needs to be restarted. If i execute that same stored procedure from SQL Plus, it runs fine.
    I tried a little test. I put a straight query in my java code that goes directly to that table (no stored procedure involved). It runs great through java!
    is this weird or what? my dbas have checked out all privelages and it seems that i have access to everything i could possibly need.
    If anyone has any suggestions i would love to hear them.
    thanks for your help...
    Lori - [email protected]
    null

    You can only access an object in another user's schema if you either:
    (a) Specify the 'other' schema name explicitly: SCHEMA.OBJECT
    (b) A synonymn has been created to access the object: CREATE SYNONYM OBJECT FOR SCHEMA.OBJECT.
    The user requiring the synonym should create it, or the user owning the object can create a PUBLIC synonym, if they have the authority.
    To check my hypothesis, try typing 'DESCRIBE procedure_name' from SQL*Plus as both users.

  • Calling PL/SQL Procedure In Another Schema Gives Unexpected Result

    I have a SQL Script that does this:
    conn pnr/<password for user pnr>;
    set serveroutput on;
    exec vms.disable_all_fk_constraints;
    SELECT owner, constraint_name, status FROM user_constraints WHERE constraint_type = 'R';
    and the disable_all_fk_constraints procedure that is owned by user 'vms' is defined as:
    create or replace
    procedure disable_all_fk_constraints is
    v_sql   VARCHAR2(4000);
    begin
    dbms_output.put_line('Disabling all referential integrity constraints.');
    for rec in (SELECT table_name, constraint_name FROM user_constraints WHERE constraint_type='R') loop
    dbms_output.put_line('Disabling constraint ' || rec.constraint_name || ' from ' || rec.table_name || '.');
    v_sql := 'ALTER TABLE ' || rec.table_name || ' DISABLE CONSTRAINT ' || rec.constraint_name;
    execute immediate(v_sql);
    end loop;
    end;
    When I run the SQL script, the call to vms.disable_all_fk_constraints disables the FK constrains in the 'vms' schema, whereas I wanted it to disable the FK constraints in the 'pnr' schema (the invoker of the procedure). I know that I could make this work by copying the disable_all_fk_constraints procedure to the 'pnr' schema and calling it as "+exec disable_all_fk_constraints;+" from within the SQL script but I want to avoid having to duplicate the PL/SQL procedure in each schema that uses it.
    What can I do?
    Thank you

    You have two issues to solve.
    First you need to write a packaged procedure that works with INVOKER rights. The default is DEFINER rights.
    The difference is excatly what you need. Usually the package has the rights from the schema where it is defined (=Definer rights). In your case schema VMS. Whereas you need the privileges from the user that calls the package (PNR).
    => Check out the documentation for INVOKER rights
    The second problem is that the view "user_constraints" will not give the results you expect when called from inside a procedure in another schema. An alternative could be to use the view DBA_CONSTRAINTS with a filter on the owner (where owner = 'PNR'). Not sure if there are other working possibilities. Well you could create a list of constraint names that you want to disable, instead of creating the list dynamically.
    And you could have another potential disaster creeping up upon you. If you run this thing, then at this moment you don't have any referential integrity anymore. You can't be sure that you can create the FKs again after this action. This is EXTREMLY DANGEROUS. I would never ever do this in any kind of production or test database. I would be very careful when I do it on a development database.

  • Privilege for truncating a table of other schema

    Hi friends
    I need to truncate a table of other schema. What privilege the other user has to give to carry out it.
    Thanks
    Edited by: user12892846 on 01-abr-2010 15:59

    DROP ANY TABLEWhile technically correct, above is somewhat dangerous because every schema could be impacted; even SYS.
    Assume SCHEMA_A owns TABLE_A & procedure below.
    CREATE & REPLACE PROCEDURE TRUNCATE_TABLE_A
    AS
    BEGIN
    EXECUTE IMMEDIATE 'TRUNCATE TABLE TABLE_A';
    END TRUNCATE_TABLE_A;
    GRANT EXECUTE ON TRUNCATE_TABLE_A TO SCHEMA_B;
    By doing as above SCHEMA_A can control who & which table(s) can be impacted (in is own schema only).
    Edited by: sb92075 on Apr 1, 2010 7:06 PM

  • Viewing package/proc/funtion source in other schemas

    There still seems to be some problems with viewing PL/SQL source in other schemas. In TOAD, I can grant SELECT ANY DICTIONARY to a developer and they can see all source in other schemas. In SQL Developer, they see nothing. If I grant EXECUTE ANY PROCEDURE, they can see the package specs, but no body (Note: we do not want developers having this priv).
    Again, our developers need to be able to view the PL/SQL source in other schemas, without having execute privs on said objects, which is very easy in TOAD. I see this issue in many threads, but SQL Developer seems to have not progressed in this area (unless I'm doing something wrong).

    Granting select on dba_source has no affect. Sure, they can get the code from the table, but it would be nice to browse to it in the GUI. Even with "execute any procedure", the package bodies are not visible.
    I've seen similar tools that have this same issue, but somehow the developers of TOAD got it right, a long time ago even. This is the only issue that keeps our development team from jumping on board with this tool.

Maybe you are looking for