AUTHID current_user

Hello

I have a form of Oracle I connect as user ROGADM. Of this form I run the procedure PROC packed (package is defined with "authid DEFINER") in the SYSUTLADM user schema. Of the PROC, I run a stand-alone function FUNC DEFINED with 'authid current_user. Why the statement:

SELECT user FROM user_users;

return SYSUTLADM?

It should not return the ROGADM according to the documentation? (http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/subprograms.htm#i18574):

Who is the current user during execution of the subprogram?

In a sequence of calls, whenever the control is inside the subprogramme of rights Summoner, the current user is the user of the session. When a DEFINER rights routine is called, the owner of this subprogramme is the current user. The current user can change as new sub-programs are called or output of subprogrammes.

To verify that the current user is at any time, you can check the USER_USERS data dictionary view. Inside of the appellant's rights routine, the value from this point of view may be different from the value of the USER built-in function that returns the name of the user of the session.

I use 10g DB.

Thanks in advance,

Jack

When you consider the following sentence...

When a DEFINER rights routine is called, the owner of this subprogramme becomes the current user

Tags: Database

Similar Questions

  • AUTHID CURRENT_USER collect statistics

    Hi all

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production. I created a procedure that collects statistics from table using DBMS_STATS using AUTHID CURRENT_USER to SChema1.

    CREATE OR REPLACE PROCEDURE SCHEMA1.getstats ( p_schema IN VARCHAR2,
                                p_table  IN VARCHAR2)
    AUTHID CURRENT_USER
    AS
    BEGIN
            dbms_stats.gather_table_stats(ownname          => p_schema,
                      tabname          => p_table,
                      method_opt       => 'FOR ALL COLUMNS SIZE AUTO',
                      degree           => 8,
                      force            => true,
                      no_invalidate    => false);
    END;
    

    I'm trying to use the same procedure to collect statistics for a table in another schema. However, I get the error ORA-20000: impossible to analyze the TABLE ' ' SCHEMA2.» DETAIL_VALUE', insufficient privileges or does not exist

    EXEC getstats ( 'SCHEMA2','DETAIL_VALUE');
    

    I grant privileges on the table to SCHEMA1. But still get the error. I understand AUTHID CURRENT_USER will attempt to use as long as the procedure as own drawing, but still, I get the error. Can someone help me on this?

    GRANT ALL ON DETAIL_VALUE TO SCHEMA1
    

    It has nothing to do with authid user current and everything to do with the privileges. Grant on the table is not enough for you to analyze.

    SQL> conn u1/u1
    Connected.
    SQL> create table foo(bar number);                                               
    
    Table created.                                                                   
    
    SQL> grant all on foo to u2;                                                     
    
    Grant succeeded.                                                                 
    
    SQL> conn u2/u2
    Connected.
    SQL> exec dbms_stats.gather_table_stats('U1', 'FOO');
    BEGIN dbms_stats.gather_table_stats('U1', 'FOO'); END;                           
    
    *
    ERROR at line 1:
    ORA-20000: Unable to analyze TABLE "U1"."FOO", insufficient privileges or does
    not exist
    ORA-06512: at "SYS.DBMS_STATS", line 33859
    ORA-06512: at line 1                                                             
    
    SQL> conn / as sysdba
    Connected.                                                                       
    
    SQL> grant analyze any to u2;                                                    
    
    Grant succeeded.                                                                 
    
    SQL> conn u2/u2
    Connected.
    SQL> exec dbms_stats.gather_table_stats('U1', 'FOO');                            
    
    PL/SQL procedure successfully completed.
    
  • A question about AUTHID CURRENT_USER

    Assume that we the users U1 and U2.
    There is a table in U1:
    create table U1.tbl (field1 integer);
    There is no subsidy on the table to any user.

    Also, there is a procedure in U1:
    create or replace procedure U1.proc AUTHID CURRENT_USER
    is begin
    insert into U1.tbl (field1) VALUES (1);
    end;
     
    grant execute on U1.proc to U2;
    Of course, if U2 executes the procedure he will get message error "table does not exist', due to AUTHID CURRENT_USER (U2 a grant on U1.tbl). The same situation is if we change the procedure as follows:
    create or replace procedure U1.proc authid current_user
    is begin
    execute immediate 'insert into U1.tbl (field1) VALUES (1)';
    end;
     
    grant execute on U1.proc to U2;
    It is very good and it should work like that.

    But we will create a new procedure (with no subsidy thereon to other users)
    create or replace procedure U1.execute_text(v_statement varchar2)
    is begin
    execute immediate v_statement;
    end;
    And change the PROC procedure as follows:
    create or replace procedure U1.proc AUTHID CURRENT_USER
    is begin
    U1.execute_text('insert into U1.tbl (field1) VALUES (1)');
    end;
     
    grant execute on U1.proc to U2;
    Then if U2 executes the procedure it will receive no error and the statement ends perfectly. The question is: why U2 can 'see' the U1.execute_text object in the body of U1. PROC (when he have subsidies on that)? In other words: he can't see tables but you can see procedures, it is very strange...

    Documentation:

    The property of a stored PL/SQL unit AUTHID influences name resolution and privilege audit of SQL statements that emits from the device at run time.

    Thus, it does not affect the name resolution and privilege checking of PL/SQL program units being called... Only SQL statements.

  • Is there a way I can find the AUTHID set of PL/SQL?

    If I am logged in as A user and I have a query a view that calls a function of authid DEFINER belonging to user B, and it called as a function of the user current authid owned by C that I am not some priivileges of the user whose second service runs under. I think it should be A but y at - it a routine system that I can call that tells me for certain that it is?
    Keith.

    Is there a way I can find the AUTHID set of PL/SQL?

    You can view the current_schema:

    SQL> create or replace procedure p1
       authid definer
    as
    begin
       dbms_output.put_line ('P1 :' || sys_context ('userenv', 'current_schema'));
    end p1;
    /
    Procedure created.
    
    SQL> create or replace procedure p2
       authid current_user
    as
    begin
       dbms_output.put_line ('P2 :' || sys_context ('userenv', 'current_schema'));
    end p2;
    /
    Procedure created.
    
    SQL> grant execute on p1 to scott
    /
    Grant complete.
    
    SQL> grant execute on p2 to scott
    /
    Grant complete.
    
    SQL> connect scott/tiger@oracle
    Connected as SCOTT@oracle
    
    SQL> exec michael.p1
    P1 :MICHAEL
    PL/SQL procedure successfully completed.
    
    SQL> exec michael.p2
    P2 :SCOTT
    PL/SQL procedure successfully completed.
    
  • How to pass hardcodded value to current_user

    Hi all

    I use AUTHID CURRENT_USER in my package in a case, I login as user 'C', but I want to spend 'CURRENT_USER' as a 'B '. How can I send user name 'B' even if my current user 'C '. All those who help is very appreciated.

    Thank you

    Don't know if that's quite what you hear, but we can do that...

    SQL> conn b/b
    Connected.
    SQL>
    SQL> create or replace procedure p1
      2      authid current_user
      3  is
      4  begin
      5      dbms_output.put_line('user = '||user);
      6      dbms_output.put_line('session_user = '||sys_context('userenv', 'session_user'));
      7      dbms_output.put_line('session_schema = '||sys_context('userenv', 'sesson_schema'));
      8      dbms_output.put_line('current_user = '||sys_context('userenv', 'current_user'));
      9      dbms_output.put_line('current_schema= '||sys_context('userenv', 'current_schema'));
     10  end p1;
     11  /
    
    Procedure created.
    
    SQL>
    SQL> grant execute on p1 to a
      2  /
    
    Grant succeeded.
    
    SQL> grant execute on p1 to c
      2  /
    
    Grant succeeded.
    
    SQL>
    SQL> conn a/a
    Connected.
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> exec b.p1
    user = A
    session_user = A
    session_schema = A
    current_user = A
    current_schema= A
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> alter session set current_schema=c
      2  /
    
    Session altered.
    
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> exec b.p1
    user = A
    session_user = A
    session_schema = C
    current_user = A
    current_schema= C
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL>
    

    Cheers, APC

    blog: http://radiofreetooting.blogspot.com

    Published by: APC on July 8, 2009 15:48

    Re-formatting of code for readability

  • dbms_scheduer autid current_user problem

    Hi all

    We have updated our database of Oracle 9i to Oracle 11 g. We were using DBMS_JOB to run all of our jobs and now we spent in DBMS_SCHEDULER. Everything works fine, but we have faced a problem with calling procedures of jobs defined as rights of the appellant.

    We have a procedure including the header as follows:

    CREATE PROCEDURE "* ORAPROG". "REF_TR_TEMP_JOB * ' (SMTRNO NUMBER DEFAULT NULL, NOSM NUMBER default NULL) AUTHID CURRENT_USER IS."
    .....
    ......
    .....

    and you use Oracle OEM, we have created the following POSITION

    BEGIN
    () sys.dbms_scheduler.create_job
    job_name = > ' "' * REGJOBS" "." " "REF_TEMP *" '.
    job_type = > 'procedure_stockee ',.
    job_action = > ' "' * ORAPROG" "." " "REF_TR_TEMP_JOB *" '.
    repeat_interval = > ' FREQ = DAILY; BYHOUR = 5; BYMINUTE = 0; BYSECOND = 0',
    start_date = > to_timestamp_tz ('2009-03-16 Asia/Jerusalem ',' YYYY-MM-DD TZR').
    job_class = > ' «DEFAULT_JOB_CLASS»»
    auto_drop = > FALSE,
    activated = > FALSE);
    sys.dbms_scheduler.set_attribute (name = > ' 'REGJOBS'.) ' ' REF_TEMP ' ', attribute = > 'logging_level', value = > DBMS_SCHEDULER. LOGGING_OFF);
    sys.dbms_scheduler.set_attribute (name = > ' 'REGJOBS'.) (' ' REF_TEMP ' ', attribute = > 'job_weight', value = > 1);
    sys.dbms_scheduler. Enable (' "REGJOBS".) ("' REF_TEMP" ');
    END;

    We noticed the TASK does not run as expected and the entitlement of the applicant is not at all considered. Notwithstanding, the work is in the schema REGJOBS, it runs as a SYS. Also, connect us as a REGJOBS and run the task... the same problem happened

    We have granted the user REGJOBS the privilege to CREATE a TASK and recreate the work of in the REGJOBS schema, then we log in as REGJOBS and run the task, it has worked. We also connect as SYS and run the job and it also worked well.

    Does this mean that we create a schema REGJOBS from work? Can't I create the SYS user work in the REGJOBS schema as above?

    Any help will be appreciated

    It is preferable to create your objects in the schema is that they are supposed to be created. If you check the view from schedulerjobs, you will see that your work has an owner, but also a job_creator. In your case, the owner was REGJOBS and the job_owner SYSTEM, which seems to become the owner of the process. This is different from what is normally expected, but when following the principle: "use the correct account to do the job" is everything works as expected.

    Best regards
    Ronald
    http://ronr.blogspot.com

  • Procedural error the call for VARRAY String as parameter

    Hello

    I get the error during the call to the procedure:

    Here are the steps:

    CREATE or REPLACE TYPE PART_TYPE IS an OBJECT (part_number VARCHAR2 (120));

    CREATE OR REPLACE TYPE PART_REC_TBL IS VARRAY (1000) of PART_TYPE ;

    I have a stored procedure in the package:

    create or replace package TEST_PART_SEARCH_PKG AUTHID CURRENT_USER AS

    PROCEDURE ADD_TO_PART)

    p_part_number_list IN PART_REC_TBL ,

    p_ord_number IN Varchar2,

    x_error_flag OUT Varchar2,

    x_error_msg OUT Varchar2

    );

    end TEST_PART_SEARCH_PKG;

    When I call the Package:

    DECLARE

    v_flag varchar2 (100);

    v_err_msg varchar2 (100);

    BEGIN

    TEST_PART_SEARCH_PKG. ADD_TO_PART ('09031518,0897701 ',' 003146M 56', v_flag, v_err_msg);

    END;

    error report-

    ORA-06550: line 5, column 6:

    PLS-00306: wrong number or types of arguments in the call to 'ADD_TO_PART '.

    ORA-06550: line 5, column 6:

    PL/SQL: Statement ignored

    It would be helpful if someone can help me on this

    Obviously. There are no part_number, so turn in your package and get rid of it:

    FOR indx1 IN 1.p_lot_number_list. COUNTY

    LOOP

    BEGIN

    SELECT

    inventory_item_id

    IN

    var_item_id

    Of

    test_part_number_v

    WHERE

    PART_NUMBER = p_part_number_list (indx1);

    EXCEPTION

    WHILE OTHERS THEN

    var_item_id: = NULL;

    END;

    SY.

  • insufficient privileges when you create sequence using the procedure

    CREATE OR REPLACE PROCEDURE schema1.proc1 AS
    BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE schema1.add_ins_seq';
    EXECUTE IMMEDIATE 'CREATE SEQUENCE schema1.add_ins_seq MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 1000 NOORDER  NOCYCLE';
    END;
    

    This procedure is created to schema1 by schema1.

    Schema1 boasts a CREATE SEQUENCE privilege.

    When I run this procedure through SQL Developer after the Cup to schema1, the error is thrown in insufficient privilege to CREATE SEQUENCE, however, DROP SEQUENCE is executed. I can create the sequence without the procedure call.

    If I add AUTHID CURRENT_USER so I don't get the error of insufficient privileges.

    Why it gives this error when the owner and the applicant of the procedure is schema1?

    Hello

    1st thing to know: when a procedure is defined (and updated), any privileges granted through ROLE is not taken into account. This is because these privileges can be active or not at the level of the session (as happens if for example a user has active 'role A' in session 1 but not in session 2 and if this role has been used to define a procedure?) The proecedure must at the same time be VALID in session 1 and INVALID session 2? Is not possible.

    Thus, for instance in a situation of 'standard': user SYSTEM has 'DBA Rôle', so you can for example make a sqlplus session "SELECT * v $ instance;", but you would write a procedure owned by system making instance_name SELECT INTO l_variable OF v$ instance;  "then"surprise": the procedure cannot be compiled because of the ORA-904 Table or view does not exist..." To be able to create the procedure, a DSS system needs to be done.

    2nd thing for your special case, a little more complex: default for a procedure is 'AUTHID DEFINE', but once more: it means "privileges of the author creating the procedure", so without taking into account the acquired privileges through roles... Your user name is 'sequence create' through a role, it cannot use the privilege within the procedure.  But... but when you define the procedure with AUTHID CURRENT_USER, privileges are evaluated at run time, and thanks to the active ROLE in the session by calling the procedure, at this time, the user can create the sequence.  If try again you but with 'The VALUE NONE ROLE' in the session before the call, you will again have the question.

    Conclusion: If you need to do the action, you must grant the user the necessary privilege directly.

    Best regards

    Bruno Vroman.

  • Select the data in a table and update in another table

    Dear experts,

    create the table TB_ENCRYPT

    (

    Identification number,

    Varchar2 (200) KEY

    );

    INSERT INTO TB_ENCRYPT VALUES(1,'HJUVHDUIFBSDGVU');

    SELECT * FROM TB_ENCRYPT;

    1 HJUVHDUIFBSDGVU

    create TABLE users)

    username, NUMBER of

    password VARCHAR2 (200)

    );

    Insert users

    values (1, 123 # "")

    Insert users

    values (2, 456 #')

    Select * from users;

    1 123 #.

    # 2 456

    I want to select the data KEY for table TB_ENCRYPT column and update in the column of tables for the respective key user password

    TB_ENCRYPT table contains only a single key value. Comparing this key, I want to update the old value of the key to the new value.

    For encryption and decryption I followed the java class method.no is worried about that.

    create or replace

    PACKAGE PCK_ENC AUTHID CURRENT_USER AS

    FUNCTION DECRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.decrypt (java.lang.String, java.lang.String) return java.lang.String ';

    FUNCTION ENCRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.encrypt (java.lang.String, java.lang.String) return java.lang.String ';

    END;

    SELECT PCK_ENC. ENCRYPT('1234','HJUVHDUIFBSDGVU') FROM DUAL;

    HERE,

    1234 - is the password of the users table column data

    HJUVHDUIFBSDGVU - represents the key of table TB_ENCRYPT column data.

    Comparing this key, I want to update the old value of the key to the new value.

    I tried with this method

    declare

    cursor c1 is

    Select the key

    of TB_ENCRYPT

    where id = 1

    update the id;

    Start

    for c1_rec looping c1

    update users

    password is PCK_ENC. Encrypt (Password, Key)

    the location being c1;

    commit;

    end loop;

    end;

    /

    Help, please

    You can use the MERGE statement.

    merge into users
    using tb_encrypt
       on (id = userid)
      when matched then
          update set password = PCK_ENC.ENCRYPT(password,key);
    

    And why you encrypt your password. This isn't a good idea. Just password hash.

  • DBMS_REDEFINITION package leads to a PLS00201 compilation error

    I try to put a logic of redefining online within a packet but direct issues, in particular the package doesn't seem to know DBMS_REDEFINITION. I can run DBMS_REDEFINITION, only not go in a package or a program named.

    Here is a minimal example that fails:

    -- Executed by the same user
    -- This works just fine:
    BEGIN
      DBMS_OUTPUT.PUT_LINE(SYS.DBMS_REDEFINITION.CONS_USE_ROWID);
    END;
    
    
    -- This generates PLS-00201 error on SYS.DBMS_REDEFINITION:
    CREATE OR REPLACE PACKAGE testpkg
      AUTHID CURRENT_USER
    AS
      gc_int PLS_INTEGER := SYS.DBMS_REDEFINITION.CONS_USE_ROWID;
    END testpkg;
    
    
    -- This does not work because testpkg is invalid:
    BEGIN
      DBMS_OUTPUT.PUT_LINE(testpkg.gc_int);
    END;
    

    The problem is that I can run these instructions to the same user within the same session and I still get the error PLS. I even ran on my own system of sandbox (12 c VM) where I have system privileges, but it does not work. I fiddled with the AUTHID clause but that did not help.

    Related discussions:

    Any suggestions?

    How grant you permission to this user to use dbms_redefinition? It must be a direct subsidy without a role:

    Connected to:
    Oracle Database 11g Release 11.2.0.4.0 - 64bit Production                      
    
    SQL> CREATE OR REPLACE PACKAGE testpkg
      2    AUTHID CURRENT_USER
      3  AS
      4    gc_int PLS_INTEGER := SYS.DBMS_REDEFINITION.CONS_USE_ROWID;
      5  END testpkg;
      6  /                                                                         
    
    Warning: Package created with compilation errors.                              
    
    SQL> drop package testpkg;                                                     
    
    Package dropped.                                                               
    
    SQL> conn / as sysdba
    Connected.                                                                     
    
    SQL> grant all on dbms_redefinition to hr;                                     
    
    Grant succeeded.                                                               
    
    SQL> conn hr/hr
    Connected.
    SQL> CREATE OR REPLACE PACKAGE testpkg
      2    AUTHID CURRENT_USER
      3  AS
      4    gc_int PLS_INTEGER := SYS.DBMS_REDEFINITION.CONS_USE_ROWID;
      5  END testpkg;
      6  /                                                                         
    
    Package created.
    
  • GotoWorkspace in after Logon trigger

    Our users want to switch automatically to the last workspace they use when they connect.  Because they can use one of several applications, I decided to put this feature in a logon after tripping on the database.

    The trigger, the tables and procedures are owned by the user WM_UTILS:

    ----------------------------

    create table wm_utils.recent_user_workspaces

    (username varchar2 (30 bytes) primary key

    nom_espace_de_travail varchar2 (30 byte));

    create or replace procedure wm_utils.goto_last_workspace authid current_user as

    pragma autonomous_transaction;

    last_workspace varchar2 (30);

    Start

    last_workspace: = get_last_workspace();

    If (last_workspace is not null) then

    dbms_wm. GotoWorkspace (last_workspace);

    end if;

    commit;

    end;

    create or replace procedure wm_utils. set_last_workspace (workspace in varchar2) as

    Start

    merge into recent_user_workspaces

    using double on (username = user)

    When not matched then insert (username, nom_espace_de_travail) values (user, workspace)

    when matched, then update set nom_espace_de_travail = workspace;

    end;

    create or replace function wm_utils. get_last_workspace return varchar2 as

    workspace varchar2 (30);

    Start

    Select nom_espace_de_travail

    in the workspace

    of recent_user_workspaces

    where username = user;

    Returns the workspace;

    exception

    When NO_DATA_FOUND then

    Returns a null value.

    end;

    create or replace procedure wm_utils.goto_workspace (workspace in varchar2) authid CURRENT_USER as

    PRAGMA AUTONOMOUS_TRANSACTION;

    Start

    dbms_wm. GotoWorkspace (workspace);

    set_last_workspace (Workspace);

    commit;

    end;

    create or replace trigger wm_utils.on_login

    After logon on database

    Start

    goto_last_workspace(); 

    exception

    while others then

    null;

    end;

    ------------------------------------------------------

    Call wm_utils.goto_workspace instead of dbms_wm. GotoWorkspace if they want to remember their choice for their next login.

    The problem is that this operation fails with the error "ORA-20073: sufficient privileges to ACCESS the workspace: 'TEST_WORKSPACE'."  It is a work space owned by the user attempting to log on, but there no privileges granted explicitly.  The user can call wm_utils.goto_last_workspace () to be identified and it works.  Y at - it something on the way in which work orders that would prevent from working in a trigger AFTER logon?

    Hello

    Triggers have the same privileges as a DEFINER procedure/function.  So, once the wm_utils.on_login trigger is executed when a user connects to the database, all the procedures performed as a result of the trigger are executed with the privileges of the wm_utils schema.  This includes even those defined as authid current_user, since at this moment in time wm_util is essentially the user that executes the procedure.  So, you can create a DEFINER rights procedure in the scheme of each user to manage dbms_wm of execution. GotoWorkspace which will remove the privileges of the user running, or give the privilege of system ACCESS_ANY_WORKSPACE wm_utils schema using dbms_wm. GrantSystemPriv.

    Kind regards

    Ben

  • The invoker rights and calling DEFINER brought

    Hi all

    I tried under scenario where I found that when I created several package in a schema S1 (packages are test_pkg1 and test_pkg2), where test_pkg1 is called in test_pkg2 package with the appellant's rights and granted in test_pkg2 the right to another schema S2.

    But when I connect to another schema S2 and I tried running test_pkg2 running test_pkg1. However, I did get his rights to the schema S2.

    Question: Rights of the said appellant, program runs according to the user rights of the session. Here only test_pkg2 execution right has a range of schema S2 for when the session is initiated, then why oracle run test_pkg1?

    Connection to the S1 schema

    CREATE OR REPLACE PACKAGE TEST_PKG1
    AUTHID CURRENT_USER
    AS 
    PROCEDURE PR_1;
    END;
    /
    CREATE OR REPLACE PACKAGE BODY TEST_PKG1
    IS
    pROCEDURE PR_1
    AS
    BEGIN
        DBMS_OUTPUT.PUT_LINE('INSIDE TEST_PKG1');
    END;
    END;
    /
    CREATE OR REPLACE PACKAGE TEST_PKG2
    AUTHID CURRENT_USER
    AS 
    PROCEDURE PR_2;
    END;
    /
    CREATE OR REPLACE PACKAGE BODY TEST_PKG2
    IS
    pROCEDURE PR_2
    AS
    BEGIN
        DBMS_OUTPUT.PUT_LINE('INSIDE TEST_PKG2');
        DBMS_OUTPUT.PUT_LINE('CALLING TEST_PKG1');
        TEST_PKG1.PR_1;
    END;
    END;
    /
    GRANT ALL ON TEST_PKG2 TO S2;
    

    Connection to the S2 schema

    CREATE OR REPLACE PACKAGE TEST_PKG3
    AUTHID definer
    AS 
    PROCEDURE PR_3;
    END;
    /
    CREATE OR REPLACE PACKAGE BODY TEST_PKG3
    IS
    pROCEDURE PR_3
    AS
    BEGIN
        DBMS_OUTPUT.PUT_LINE('INSIDE TEST_PKG3');
        DBMS_OUTPUT.PUT_LINE('CALLING TEST_PKG2');
         RV2811.TEST_PKG2.PR_2;
    END;
    END;
    /
    
    EXEC TEST_PKG3.PR_3;
    

    Output

    INSIDE TEST_PKG3
    CALLING TEST_PKG2
    INSIDE TEST_PKG2
    CALLING TEST_PKG1
    INSIDE TEST_PKG1
    

    Directly from the documentation (http://docs.oracle.com/database/121/DBSEG/dr_ir.htm#DBSEG99926)

    For all other external references, such as direct PL/SQL function calls, Oracle database verifies the rights of the owner at compile time, but does not perform a check of the execution. Therefore, the user of the procedure of the appellant's rights doesn't have privileges on external references outside DML or dynamic SQL statements. Otherwise, the developer of the procedure of the appellant's rights should only grant privileges on the procedure itself and not on all referenced objects directly by procedure rights of the appellant.

  • ERROR 72 line, col 5, ending_line 72, ending_col 9, found "BEGIN", Expecting: EXTERNAL LANGUAGE

    Hello

    While run below Package and the body, I get the error message "ERROR 72 line, col 5, ending_line 72, ending_col 9, found"BEGIN", Expecting: LANGUAGE EXTERNAL.

    CREATE OR REPLACE PACKAGE APPS. ASO_QUOTE_CUHK AUTHID CURRENT_USER as

    PROCEDURE Create_quote_PRE)

    P_Validation_Level IN NUMBERS NOCOPY,

    P_Control_Rec IN OUT NOCOPY ASO_QUOTE_PUB. Control_Rec_Type,

    P_Qte_Header_Rec IN OUT NOCOPY ASO_QUOTE_PUB. Qte_Header_Rec_Type,

    P_hd_Price_Attributes_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Price_Attributes_Tbl_Type,

    P_hd_Payment_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Payment_Tbl_Type,

    P_hd_Shipment_Rec IN OUT NOCOPY ASO_QUOTE_PUB. Shipment_Rec_Type,

    P_hd_Freight_Charge_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Freight_Charge_Tbl_Type,

    P_hd_Tax_Detail_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Tax_Detail_Tbl_Type,

    P_hd_Attr_Ext_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Line_Attribs_Ext_Tbl_Type,

    P_hd_Sales_Credit_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Sales_Credit_Tbl_Type,

    P_hd_Quote_Party_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Quote_Party_Tbl_Type,

    P_Qte_Line_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Qte_Line_Tbl_Type,

    P_Qte_Line_Dtl_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Qte_Line_Dtl_Tbl_Type,

    P_Line_Attr_Ext_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Line_Attribs_Ext_Tbl_Type,

    P_line_rltship_tbl IN OUT NOCOPY ASO_QUOTE_PUB. Line_Rltship_Tbl_Type,

    P_Price_Adjustment_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Price_Adj_Tbl_Type,

    P_Price_Adj_Attr_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Price_Adj_Attr_Tbl_Type,

    P_Price_Adj_Rltship_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Price_Adj_Rltship_Tbl_Type,

    P_Ln_Price_Attributes_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Price_Attributes_Tbl_Type,

    P_Ln_Payment_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Payment_Tbl_Type,

    P_Ln_Shipment_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Shipment_Tbl_Type,

    P_Ln_Freight_Charge_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Freight_Charge_Tbl_Type,

    P_Ln_Tax_Detail_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Tax_Detail_Tbl_Type,

    P_ln_Sales_Credit_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Sales_Credit_Tbl_Type,

    P_ln_Quote_Party_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. Quote_Party_Tbl_Type,

    P_Related_Obj_Tbl IN OUT NOCOPY ASO_QUOTE_PUB. RELATED_OBJ_Tbl_Type,

    X_Return_Status OUT NOCOPY / * file.sql.39 change * / VARCHAR2,.

    X_Msg_Count OUT NOCOPY / * file.sql.39 change * / NUMBER,.

    X_Msg_Data OUT NOCOPY / * file.sql.39 change * / VARCHAR2

    ) AS

    BEGIN

    NULL;

    END;

    END APPS. ASO_QUOTE_CUHK;

    Thank you

    You're hurting. This example shows the creation of a package body. Your original code illustrates creating a package.

  • Parallelize a procedure call

    Is there a simple way to call a parallel procedure?

    I wan't something like this:

    declare

    int l_first;

    int l_second;

    int l_third;

    Start

    l_first: = start_new_thread ('call my_procedure (1)');

    l_second: = start_new_thread ('call some_procedure (2)');

    l_third: = start_new_thread ('call some_procedure (3)');

    join_thread (l_first);

    join_thread (l_second);

    join_thread (l_third):

    end;

    The variant when you create task, create pieces, run the task and after all you drop the task is not convenient I want to just run my procedure in new thread, I don't need to chunk of other tables by rowid or something else.

    It seems that you want to use threading and not necessarily parallel processing.

    The difference? Well, parallel processing takes a load of unique work and that at the same time (hence the need for segmentation of the workload). Threads can be performed in parallel of the different workloads - for example in a a Flight Simulator thread can do the rendering, another sound, another model flight, another weather model, etc.

    And this (and other) announces, is seems you want to put on and treatment not specifically parallel.

    We can implement as background process threads (aka jobs).  But unlike the typical Windows/Posix thread synchronization between threads and access for the threads data segment, are not really possible.

    Here is an example of a class Thread base to be used in PL/SQL:

    SQL> create or replace type TThread authid current_user as object(
      2          thread_code     varchar2(32767),
      3          job_id          integer,
      4
      5          constructor function TThread( plsqlCode varchar2, startImmediate boolean default true ) return self as result,
      6          member procedure StartThread(  self in out TThread ),
      7          member function ThreadCompleted return boolean
      8  );
      9  /
    
    Type created.
    
    SQL>
    SQL> create or replace type body TThread as
      2
      3          constructor function TThread( plsqlCode varchar2, startImmediate boolean default true ) return self as result is
      4          begin
      5                  self.thread_code := plsqlCode;
      6                  if startImmediate then
      7                          self.StartThread();
      8                  end if;
      9                  return;
    10          end;
    11
    12          member procedure StartThread( self in out TThread ) is
    13                  pragma autonomous_transaction;
    14          begin
    15                  DBMS_JOB.Submit(
    16                          job => self.job_id,
    17                          next_date => sysdate,
    18                          what => self.thread_code
    19                  );
    20                  commit;
    21          exception when OTHERS then
    22                  rollback;
    23                  raise;
    24          end;
    25
    26          member function ThreadCompleted return boolean is
    27                  i       integer;
    28          begin
    29                  select 1 into i from user_jobs where job = self.job_id;
    30                  return( false );
    31          exception when NO_DATA_FOUND then
    32                  return( true );
    33          end;
    34
    35  end;
    36  /
    
    Type body created.
    
    SQL>
    SQL> declare
      2          thread1 TThread;
      3  begin
      4          thread1 := new TThread( 'dbms_lock.sleep(10);' );
      5          dbms_output.put_line( to_char(sysdate,'hh24:mi:ss')||': thread running as job '||thread1.job_id );
      6
      7          while not thread1.ThreadCompleted() loop
      8                  dbms_output.put_line( to_char(sysdate,'hh24:mi:ss')||': thread busy...' );
      9                  dbms_lock.sleep(1);
    10          end loop;
    11
    12          dbms_output.put_line( to_char(sysdate,'hh24:mi:ss')||': thread completed' );
    13
    14  end;
    15  /
    07:52:50: thread running as job 767
    07:52:50: thread busy...
    07:52:51: thread busy...
    07:52:52: thread busy...
    07:52:53: thread busy...
    07:52:54: thread busy...
    07:52:55: thread busy...
    07:52:56: thread busy...
    07:52:57: thread busy...
    07:52:58: thread busy...
    07:52:59: thread busy...
    07:53:00: thread busy...
    07:53:01: thread busy...
    07:53:02: thread busy...
    07:53:03: thread completed
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    Note that no validation is to ensure that the StartThread() method is not called repeatedly - this class is a simple test model that has yet to evolve before production use.

  • ORA-01031: insufficient privileges in ORACLE 8.0.5


    Hi all


    Can you help me please:


    IM using ORACLE 8.0.5



    I made this package:

    ORACLE 8.0.5

    CREATE OR REPLACE PACKAGE BODY MULTIFOX. PAQ_MULTIFOX AS

    PROCEDURE REVISA_CRED IS

    BEGIN

    UPDATE / * + BYPASS_UJVC * /.

    (

    SELECT IF NECESSARY. CDGNS, PRN. CICLO, PRN. CANTAUTOR, MPD. NF

    OF MULTIFOX. MPD MPD,

    SIACOM. NRP NRP

    WHERE MPD. CDGNS = PRN. CDGNS AND MPD. CICLO = PRN. CICLO

    AND THE LBD. CANTAUTOR > 0

    ) NF SET = null;

    COMMIT;

    END;

    END PAQ_MULTIFOX;

    /

    CREATE OR REPLACE PACKAGE MULTIFOX. PAQ_MULTIFOX AS


    PROCEDURE REVISA_CRED;

    END PAQ_MULTIFOX;

    When I call this procedure of Toad SQLEditor I get this error

    Capturado.gif

    If I run the script directly in TOAD sqleditor, it works great!

    Capturado.gif

    I have connected to the schema SIACOM one gave all permisions them user MULTIFOX,.


    GRANT CONNECT TO MULTIFOX;

    GRANT DBA TO MULTIFOX;

    MULTIFOX GRANT RESOURCE;

    GRANT SELECT ANY TABLE TO MULTIFOX;

    GRANT EXECUTE ANY PROCEDURE TO MULTIFOX;

    GRANT SELECT, INSERT ON SIACOM. PD FOR MULTIFOX;

    GRANT SELECT, INSERT ON SIACOM. PDI TO MULTIFOX;

    but don't solve it, get the same error (ORA-01031: insufficient privileges)

    When I add the AUTHID CURRENT_USER clause to the definition of the package, had this error in compiling...

    Capturado.gif

    What Miss me?

    Thanks in advance. !



    But isn't your request doing an UPDATE? A right to select is not help with that.

    The best way to solve the problems related to the privilege is to remove all of THE objects except for one a simple query and see if it works. If she adds another object of return and test this.

    You will find the problem object when it fails.

Maybe you are looking for

  • Satellite Pro A100 RAM upgrade

    Hey I recently tried to upgrade the 512 MB in my laptop with an additional 1 GB from the internet.These two channels work individually, but when I try to start both installed, the screen turns off at startup but pc is ongoing execution and all the ri

  • Maximum frequency for digital counter input

    Hello world to measure the speed of a rotating wheel, US 36 in a disc holes and detect with an optical sensor of rotation. Which means that the maximum speed of the wheel or our optical sensor will output a TTL Signal with a frequency of 3200 Hz. (32

  • SLOW FREEZING

    Hello MY COMPUTER HAS SUDDENLY BECOME VERY SLOW AND IT FREEZES ALL THE TIME. I'VE DONE THE SCANNER SECURITY AND EVERYTHING'S FINE. PLEASE, WHAT SHOULD I DO TO FIX THIS? Thank you :)

  • Computer won't download any programs on the net

    I am running Windows XP Home Edition SP3 and Firefox.  When I click on a program to download, the installation program appears, click on save or run... to get a Firefox window showing Setup search virus... window becomes empty.  Few pop up in the bar

  • Upgrade memory on HP Pavilion g6

    Hello My HP Pavilion g6-1185sa with 4 GB RAM can be upgraded to a larger amount of RAM? If so what is the maximum and what type to use? Thank you