insufficient privileges when using dynamic sql statements in the procedure

Hello
I use following script on oracle 10g. and get the error not enough privs. Please advice.

SQL > show user
The user is 'GRSADM '.
SQL > create or replace procedure grsadm.test_proc as
a varchar2 (2000);
Start
a: =' VIEW to CREATE or REPLACE
TEST_VIEW
IN SELECT
"FLAS" one
THE DOUBLE ';
immediately run one;
end;
Created procedure.
SQL > start
grsadm.test_proc;
end;
Start
grsadm.test_proc;
end;
Error on line 16
ORA-01031: insufficient privileges
ORA-06512: at "GRSADM. TEST_PROC', line 9
ORA-06512: at line 2

SQL > select * from session_privs
where the privilege as "VIEW %.

PRIVILEGE
----------------------------------------
CREATE A VIEW
REMOVE ANY VIEW
CREATE A MATERIALIZED VIEW
MODIFY A MATERIALIZED VIEW
REMOVE ANY MATERIALIZED VIEW


5 selected lines.

Published by: Rous Sharma on November 24, 2011 12:00

GRSADM has a privilege ' CREATE (all) VIEW ' live?
And not via a role...

SSM
Samir,
GRSADM is the owner of this procedure, it seems that the EXECUTE priv, that you suggested is already involved.

Tags: Database

Similar Questions

  • Char invalid when you use dynamic sql statements with cursor

    Hello guys,.
    I'm opening a following cursor with dynamic sql
     v_sql := 'SELECT OS.table_name FROM OBJECT_STATS_CONTROL OS, ALL_TABLES AT
                    WHERE OS.analyze_flag <> ''N''
                    AND OS.last_analyze < sysdate -1 AND AT.last_analyzed < sysdate - 1 '||v_1||';'; 
    my cursor statement is
    BEGIN
           OPEN v_cur FOR v_sql; 
           LOOP
           FETCH v_cur INTO v_tabname;
    ......
    I get an error message
    0911 invalid char
    can any body suggest me where I'm wrong

    Thank you

    Remove the semicolon at the end:

    ||';'  -- remove this.
    
  • How to write the SQL without using dynamic SQL?

    How can you write this under SQL without using execute immediately?

    You can use static SQL (using something like a CASE statement)?

    test procedure (one in varchar2, b number, each number) is

    v_num_recs pls_integer;

    Start

    Select count (*)

    in v_num

    FROM table1

    where

    col1 = one and

    If b is not null then col2 = b

    If c is not null then col3 = c;

    / * i.e. If b is not null, where condition to add this line only. If c is not null, where condition should add only this line. OR condition No. it * /.

    dbms_output.put_line (v_num);

    end;

    Or should I use dynamic SQL statements for this?

    I was wondering if the two are NOT NULL? Well check this.

    Select count (*) in v_num

    table

    where col1 = one

    and col2 = (CASE WHEN (b is not null) THEN b ELSE END col2)

    and col3 = (CASE WHEN (c is not null) THEN ELSE END col3 c)

  • Display dynamic SQL statement result

    Hello

    Is it possible to view the sql statement in the procedure below, after that the variables are applied?

    In my view, a solution would be to put the entire statement in an important variable, then use DBMS_OUTPUT. Put_line (my_large_variable) but I'm hoping to save this step.

    Thanks in advance for your help,

    Lou

    create or replace
    PROCEDURE TEST1_PROC)
    p_refcur ON SYS_REFCURSOR,
    p_where in VARCHAR2,
    p_order_by in VARCHAR2
    )

    IS

    v_id ci_summrpt_report_codes.id% TYPE;
    v_descr ci_summrpt_report_codes.descr% TYPE;
    v_valid_flag ci_summrpt_report_codes.valid_flag% TYPE;
    v_order_by VARCHAR2 (100);

    BEGIN
    IF p_order_by IS NULL THEN
    v_order_by: = NULL;
    ON THE OTHER
    v_order_by: = "ORDER BY". p_order_by;
    END IF;
    DBMS_OUTPUT. Put_line (p_where);
    DBMS_OUTPUT. Put_line (v_order_by);
    P_refcur OPEN FOR ' SELECT id, descr, valid_flag OF |
    «(SELECT 1 AS 'ID', "A" AS "DESCR", "Y" AS "VALID_FLAG" OF THE DOUBLE ' |)»
    "UNION ALL" |
    "SELECT 2,"TWO","Y"OF THE DOUBLE ' |
    "UNION ALL" |
    "SELECT 3,"THREE"," Y "DOUBLE" |
    "UNION ALL" |
    SELECT 4, "FOUR", "Y" DOUBLE) ' |
    p_where |
    v_order_by
    ;
    END TEST1_PROC;

    In my view, a solution would be to put the entire statement in an important variable, then use DBMS_OUTPUT. Put_line (my_large_variable) but I'm hoping to save this step.

    This isn't a big problem, I think, is - this? :

    create or replace procedure test1_proc (p_refcur        out sys_refcursor,
                                            p_where      in     varchar2,
                                            p_order_by   in     varchar2)
    is
       v_id           ci_summrpt_report_codes.id%type;
       v_descr        ci_summrpt_report_codes.descr%type;
       v_valid_flag   ci_summrpt_report_codes.valid_flag%type;
       v_order_by     varchar2 (100);
       v_stmt         long;
    begin
       if p_order_by is null
       then
          v_order_by := null;
       else
          v_order_by := ' ORDER BY ' || p_order_by;
       end if;
    
       dbms_output.put_line (p_where);
       dbms_output.put_line (v_order_by);
       v_stmt :=
          'SELECT id, descr, valid_flag FROM '
          || '(SELECT 1 AS "ID", ''ONE'' AS "DESCR", ''Y'' AS "VALID_FLAG" FROM DUAL '
          || 'UNION ALL '
          || 'SELECT 2, ''TWO'', ''Y'' FROM DUAL '
          || 'UNION ALL '
          || 'SELECT 3, ''THREE'',''Y'' FROM DUAL '
          || 'UNION ALL '
          || ' SELECT 4, ''FOUR'',''Y'' FROM DUAL) '
          || p_where
          || v_order_by;
       dbms_output.put_line (v_stmt);
    
       open p_refcur for v_stmt;
    end test1_pro;
    
  • GETTING AN ERROR - slider 'P_REFCUR' cannot be used in the OPEN dynamic SQL stat

    DECLARE
    create or replace procedure partial_single (p_fileid in NUMBER, p_filename IN VARCHAR2 (2000), p_temptablename IN VARCHAR2 (2000), p_temppartialtablename IN VARCHAR2 (2000), p_retval ON the NUMBER)
    --)

    p_fileid NUMBER;
    p_filename VARCHAR2 (2000);
    p_temptablename VARCHAR2 (2000);
    p_temppartialtablename VARCHAR2 (2000);
    p_retval NUMBER;
    p_refcur types_pkg.return_cur;
    v_strquery varchar2 (4000);

    BEGIN

    p_fileid: = 5080;
    p_filename: = "TAGSUR1HM2011013111160838654.000019265";
    -p_temptablename: = "TEMP_RECORDS_MED_0004";
    p_temptablename: = 'TEMP_RECORDS_MED_DATE ';
    p_temppartialtablename: = 'TEMP_MED_PARTIAL_RECORDS_0002 ';
    p_retval: = 0;


    v_strquery: = 'SELECT imsi, connectedcallingnumber, callstart MIN (calleventstarttimestamp), SUM (calleventduration), MAX (sequence_number) sequencenumber, msisdn, max (callreleasetime) callreleasetime period';
    v_strquery: = v_strquery | ' A ' | p_temppartialtablename | ' GROUP BY connectedcallingnumber, imsi, msisdn';

    OPEN p_refcur - GETTING AN ERROR - slider 'P_REFCUR' cannot be used in a dynamic OPEN SQL statement
    FOR v_strquery;

    FOR CC IN (SELECT imsi,
    connectedcallingnumber,
    Callstart MIN (calleventstarttimestamp),
    Duration of the SUM (calleventduration),
    SequenceNumber MAX (sequence_number),
    MSISDN,
    Max (callreleasetime) callreleasetime
    OF TEMP_MED_PARTIAL_RECORDS_0002
    GROUP BY connectedcallingnumber, imsi, msisdn)

    LOOP

    UPDATE TEMP_RECORDS_MED_DATE
    SET calleventstarttimestamp = cc.callstart,
    calleventduration = calleventduration + cc.duration
    WHERE connectedcallingnumber = cc.connectedcallingnumber
    AND imsi = cc.imsi
    AND sequencenumber = cc.sequencenumber + 1
    AND msisdn = cc.msisdn
    AND calleventstarttimestamp = cc.callreleasetime;


    IF SQL % ROWCOUNT > 0
    THEN
    UPDATE TEMP_MED_PARTIAL_RECORDS_0002
    SET isprocessed = 1
    WHERE connectedcallingnumber = cc.connectedcallingnumber
    AND imsi = cc.imsi
    AND msisdn = cc.msisdn;
    - AND callreleasetime = cc.callreleasetime;

    ON THE OTHER

    UPDATE TEMP_MED_PARTIAL_RECORDS_0002
    SET calleventduration = calleventduration + cc.duration
    IMSI WHERE = cc.imsi
    AND msisdn = cc.msisdn
    AND callreleasetime = cc.callreleasetime
    AND calleventduration! = cc.duration;


    END IF;

    END LOOP;


    REMOVE FROM TEMP_MED_PARTIAL_RECORDS_0002
    WHERE isprocessed = 1;


    p_retval: = 0;

    -VALIDATION;
    / * EXCEPTION
    WHILE OTHERS
    THEN
    -RESTORATION;
    p_retval: = 1;
    p3_errorlog ("partial" p_fileid, SQLERRM, |) ':' || p_filename);
    COMMIT;
    */
    END;

    Is - what your refcursor has a return type? In this case you can not open it with dynamic SQL. Change the Refcursor as a weakly typed cursor and give it a try.

  • problem using dynamic sql

    Hi all

    I have to insert the record in a table in one database to another database which requires db_link.so to do this I use run immediately, but when I try to insert by using the procedure below it will directly itno exception block.
    Help, please



    declare
    p_study_to NUMBER: = 1;
    p_study_from NUMBER: = 3;
    P_db_link VARCHAR2 (30): = 'abc ';
    BEGIN

    RUN IMMEDIATELY ' INSERT INTO RRRRR
    (study_to, db_link, dt_created, dt_modified, modified_by)'
    ||' SELECT study_to, db_link, dt_created,
    dt_modified, modified_by
    OF UUUU@:2'
    using p_study_to, p_db_link;
    EXCEPTION
    WHILE OTHERS
    THEN
    dbms_output.put_line ('error when inserting in RRRRR');
    END;
    /


    Thanks in advance!

    Hello

    You can tell only AID like this to give values for expressions, not table names (or their qualifications, as in this case).
    Try:

    declare
         p_study_to     NUMBER := 1;
         p_study_from      NUMBER := 3;
         P_db_link      VARCHAR2(30) := 'abc';
         sql_txt          VARCHAR2 (2000);
    BEGIN
    
         sql_txt := 'INSERT INTO     RRRRR (study_to, db_link, dt_created, dt_modified, modified_by)'
              ||           ' SELECT  study_to, db_link, dt_created, dt_modified, modified_by'
              ||          ' FROM    UUUU@' || p_db_link ;
         dbms_output.put_line (sql_txt);
    
            -- EXECUTE IMMEDIATE  sql_txt;
    END;
    

    Whenever you write dynamic sql code, it displays first.
    Only when it shows something that looks right should you UN-comment the EXECUTE IMMEDIATE statement.
    Before you go into Production, comment out code (or delete) the call to put_line.

    Use an EXCEPTION handler only when you can improve on what is the mechanism of error by default, for example, you plan a particular error, and you have something specail do when this error occurs.

    Using dynamic SQL just to have the same code running on different databases, where each database needs a different connection name? If so, use synonyms instead of dynamic SQL.

  • find sql_id using the sql statement, including the carriage return and tab...

    Hello. all.

    I wonder how to find sql_id using a sql statement, including transport retrun and tab space multiple.
    To be more precise,

    My sql is:

    Select
    col_a,
    col_b,
    ..
    ..

    I usually use the following query to find the sql_id

    Select sql_id in v$ sql where sql_text like 'MY SQL STATEMENT %.

    When MY SQL STATEMENT includes carriage return and tab space multiple, how can I do?

    Thanks in advance.
    Best regards.

    Hello

    Did you look at regular expressions? Use regexp_like instead of as.

    http://www.Stanford.edu/dept/ITSS/docs/Oracle/10G/server.101/b10759/conditions018.htm

    Kind regards

  • link: new values on after the trigger by using dynamic sql.

    Hello all I have a problem I want to solve using dynamic sql on a trigger. The problem is that are around 5 qty fields who each have 18 separate fields. This is because of different sizes (S, M, L, XL, etc., up to 18). So I will try to use the: new values on a trigger to dynamically fill these information on a table, but immediate execution is run is returning the value like: new.open_sz (x) instead of the actual numeric value of the column. See code below. Is there a way to do this.

    Thank you in advance.


    CREATE OR REPLACE TRIGGER T_EXAMPLE
    after update of
    open_sz1, open_sz2, open_sz3, open_sz4, open_sz5, open_sz6,
    open_sz7, open_sz8, open_sz9, open_sz10, open_sz11, open_sz12,
    open_sz13, open_sz14, open_sz15, open_sz16, open_sz17, open_sz18
    on order_li_m for each line
    declare
    Is of TYPE NumArray table indexes number directory;
    NumArray v_orderqty;
    -TYPE VarArray is the table of the varchar2 (200) index directory.
    -v_orderqty K_A2KSTD. VarArray;
    v_col varchar2 (30);
    v_sql varchar2 (1000);
    BEGIN
    for a 1 in... 18 loop
    v_col: = ': new.open_sz' | one;
    v_sql: = ' SELECT: 1 double ';
    run immediately v_sql in v_orderqty (a) using v_col;
    dbms_output.put_line (v_orderqty (a));
    end loop;
    end T_EXAMPLE;
    /

    Raffy Martin wrote:
    Is there a way to do this.

    You may not use: news and: old identifiers in dynamic SQL, the way to do it is to specify the real column names.

  • ORA-01031 insufficient privilege when updating a table join

    Update (select a.f1, b.f2 FROM tableA a join tableB b using (fk))
    Set f1 = f2

    the user connection enough readonly privilege for tableB, but sql never update the tableB, why Oracle triggers the error?

    How can I implement the logic to update?

    UPDATE tablea a
    SET (f1, col) = (SELECT b.f2, b.col
    FROM tableb b
    WHERE = a.key b.key)

    If one given by Danish works, then you can simplify this in writing as it... even that request that eliminating two claims her...

    Ravi Kumar

    Published by: user10164479 on July 24, 2009 11:16

  • Is it possible to make the condition depending on the sql statements in the data models

    Hi all

    Is it possible to include the condition based on sql statements in the data models.

    For example
    if (some parameter is not null)
    <sqlstatement name="STATEMENT_1">
    ...
    </sqlstatement>
    else
    <sqlstatement name="STATEMENT_2">
    ...
    </sqlstatement>
    Is something like this? Also, the good doc is available for ' how to take full advantage of the "data models" in BI Publisher?

    Thank you
    -Sookie

    Hello Sookie,
    I couldn't find the time to get a data model of demonstration of work for you, but I'll try to explain.

    First, write a PL/SQL package. Make sure that you set all the parameters of model of data such as a global variable in the default PL/SQL package.

    CREATE OR REPLACE
    package as employee
    function BeforeReportTrigger return Boolean;
    query_text varchar (2000);
    number of p_DEPTNO;
    END;
    /

    CREATE OR REPLACE
    package as body employee
    function BeforeReportTrigger return Boolean IS
    Start

    IF (p_DEPTNO = 10) THEN
    query_text: = select col1, col2, col3 from HR.
    elsif (p_DEPTNO = 20) THEN
    query_text: = select col1, col2, col3 hr_history.
    on the other
    query_text: = select col1, col2, col3 hr_history1.
    end if;
    Returns true;
    end;
    /

    Use this package in the default package in your data model. Check the "defaultPackage ="employee"in the following data model header.

    Sample data model
    ------------------------------












    --
    --
    --
    --

    Before running the query SQL, data engine reads the "before the release of the report" and all the texte_requete argument based on the p_DeptNo value. When executing the Q1, engine sqlQuery analyze the query ' & quert_text and replace it with the actual value. For example if the p_deptno = 10, the query will be "select col1, col2, col3 from HR.

    Try it...

  • Displays the dates of diff using PL/SQL expression for the item "display only"?

    Hello
    I have a single display element -: P2_FROM_Date. If his game, Fri, sat or Sun I want to put the date of the last Monday date. If its Mon, Mar or sea, it must be this date of Monday.

    Ex: Today is Friday and last Monday was 18.
    So yesterday, today, tomorrow and Sunday, the date appear as June 18, 2012.
    Since Monday to Wednesday, the date has to be the next that is Monday, June 24, 2012

    I tried under 'Source' from the element using PL/SQL expression and the body of the PL/SQL function. Does not

    Can anyone help?

    Thanks and greetings
    Umer

    1. you must set 'used source' "Always".
    2 If you use a PLSQL function as source type body should set a 'RETURN' statement like this:

    declare
    lv_date number;
    begin
    select to_char(sysdate,'D') into lv_date from dual;
    if lv_date=2 then
      return to_char(sysdate-1);
    end if;
    end;
    

    Published by: mario1977 on June 27, 2012 11:44

  • Pinning on SQl statement in the library cache

    Hello
    Do to pin frequently used SQL statement to the shared pool...

    I know that dbms_shared_pool.keep does the job for PL/SQL, but on simple SQL statements.

    Experts from the clues?

    Thank you

    King

    See more of scripts:

    -- Get address and hash_value of SQL statement
    select address, hash_value from v$sql where sql_text like 'your query to keep';
    ------------------------------------------------------------------------------------------------
     00000000858CA2B0      2239673969
    
    exec dbms_shared_pool.keep('00000000858CA2B0, 2239673969','C');
    

    I think you want to pin the SQL statement that is specific to the moment analysis of long abovid.
    I see no reason to pin the SQL more.

    Dion Cho

  • After you install a Foxfire 5.0 update, I get this message when you try to open Mozilla: the procedure entry point sqlite3_db_status could not be located in the dynamic link library mozsqlite3.dll.

    I get this message when you try to open Mozilla: the procedure entry point sqlite3_db_status could not be located in the dynamic link library mozsqlite3.dll.

    Do a clean reinstall.

    Download a new copy of Firefox and save the file to the desktop.

    • Uninstall your current version of Firefox.
    • Do not remove the data of a personal nature when you uninstall the current version.

    Delete the program folder Firefox before installing newly downloaded copy of the Firefox installer.

    • It is important to remove the Firefox program folder to delete all the files and make sure that there is no problem with the files that were the remains after uninstallation.

    Your bookmarks and other profile data is stored in the Firefox profile folder and will not be affected by a relocation, but make sure that you do not select delete data of a personal nature if you uninstall Firefox.

  • When using adjustment layers, I get the message "adobe could not rasterize because pixels for this layer data are not directly editable" what's the problem?

    When using adjustment layers, I get the message "adobe could not rasterize because pixels for this layer data are not directly editable" what's the problem?

    This happens because there is no mask on adjustment and you have selected the Brush tool. You cannot paint on an adjustment. If the masks are not be created by default when you create the adjustment and you want that they be created, select mask add default option in the context menu of adjustments of the

  • 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.

Maybe you are looking for

  • How to create a strict property node.

    I have searched for a way to create a note of strict property for an entire day and still cannot get the answer. I have download a Vi from the Web site of nor, but my lab computer can not open, so I open it with my lab - top and try to reproduce them

  • Solved the problem of battery

    I think I solved the problem of unreplaceble battery. first of all, you need to do this guide on anythingbutipod. then for the battery, you can buy a broken cheap on ebay view. I hope I helped!

  • Flickering on my vista laptop for business

    helloo... for the first time here - and my knowledge is BASIC! I have a crazy flicker on my screen - he calms down after starting or overnight, but it happens every 5 seconds. any ideas? someone told me he's trying to do something... George

  • 0 x 00000076 blue screen and need help

    OK im a little new to how computers work so sorry if it's really dumbed down in the way that I ask the question. for a while I get the blue screen on my computer every time that I stop/restart my computer. It happens then, or when I disconnect my con

  • Impossible to debug in Simulator

    When I try to run a simple Hello world app in the Simulator, I get following error: Deployment failed: 1Error: Unable to connect: connection to https://192.168.93.130 refused. You may need to restart the target. I restarted the Simulator several time