limit multiple executions of a procedure

Hi all

I would limit the simultaneous executions of a procedure. In other words, you want to serialize. Pretty simple, I use locking mechanism for this, but this procedure has a parameter which is a ref cursor and the lock will be released as soon as the ref cursor is open and control reaches the end of the procedure, but I is to restrict users to not be able to perform this procedure again until the closure of this ref cursor Is it possible that this can be achieved with in Oracle DB?

Example Code:

CREATE OR REPLACE PROCEDURE SH.SALES_BY_PRODUCT(P OUT SYS_REFCURSOR) IS
BEGIN
..... --Lock here
  OPEN P FOR
    SELECT PROD_ID, SUM(AMOUNT_SOLD) AS AMOUNT FROM SH.SALES GROUP BY PROD_ID;
..... --Release the lock here --This approach of locking is not helping as the lock is released even before the cursor P is closed by the calling application.
END;

Thank you!

You could get an application lock using package of dbms_lock which can be taken on the border of a transaction (commit) until you release or the session ends.

HTH

Tags: Database

Similar Questions

  • ODI-1226: Error_log_procedure step fails after 1 attempt. ODI-1232: the execution of the procedure error_log_procedure failed. ODI-1246: the logical schema has not been defined for error_log_procedure.

    I created a procedure running during the mapping fails but I am facing this error

    ODI-1226: Error_log_procedure step fails after 1 attempt.

    ODI-1232: the execution of the procedure error_log_procedure failed.

    ODI-1246: the logical schema has not been defined for error_log_procedure.

    at oracle.odi.runtime.agent.execution.AbstractSessionTask.getCollectDwgConnectConnection(AbstractSessionTask.java:754)

    at oracle.odi.runtime.agent.execution.AbstractSessionTask.getCollectDwgConnectConnection(AbstractSessionTask.java:730)

    at oracle.odi.runtime.agent.execution.SessionTask.getExecutor(SessionTask.java:239)

    at oracle.odi.runtime.agent.execution.SessionTask.processTask(SessionTask.java:152)

    at oracle.odi.runtime.agent.execution.SessionTask.doExecuteTask(SessionTask.java:111)

    at oracle.odi.runtime.agent.execution.AbstractSessionTask.execute(AbstractSessionTask.java:864)

    to oracle.odi.runtime.agent.execution.SessionExecutor$ SerialTrain.runTasks (SessionExecutor.java:2024)

    at oracle.odi.runtime.agent.execution.SessionExecutor.executeSession(SessionExecutor.java:562)

    to oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$ 1.doAction(TaskExecutorAgentRequestProcessor.java:718)

    to oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$ 1.doAction(TaskExecutorAgentRequestProcessor.java:611)

    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:203)

    at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doProcessStartAgentTask(TaskExecutorAgentRequestProcessor.java:800)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 1400 (StartSessRequestProcessor.java:74)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:702)

    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:180)

    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:108)

    to java.util.concurrent.Executors$ RunnableAdapter.call (Executors.java:471)

    at oracle.odi.runtime.agent.execution.job.OdiJob.call(OdiJob.java:73)

    at oracle.odi.runtime.agent.execution.job.OdiJob.call(OdiJob.java:73)

    at java.util.concurrent.FutureTask.run(FutureTask.java:262)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    to java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:615)

    at java.lang.Thread.run(Thread.java:724)

    Navigate to the ODI object with the name error_log_procedure , which I assume is an ODI procedure. On the target tab (and if this source) make sure that you have specified a logical schema in the appropriate drop-down box

  • why there is no output after execution of the procedure

    Hi all

    SQL > set serveroutput size 1000000

    SQL > set echo on

    SQL > set comments on

    SQL > declare

    2 number (19) n;

    3 v_startday varchar2 (100): = ' 01 /' 07/2013;

    4 v_owner varchar2 (100): = "SLIMSINTDM";

    5 v_audit_tab audit_var: = audit_var();

    v_table_name 6 varchar2 (40);

    7 type cur_type is ref cursor;

    8 v_cur cur_type.

    v_first_name 9 varchar2 (100);

    v_last_name 10-varchar2 (100);

    11 v_out_tab varchar2 (100);

    v_lab_code 12 varchar2 (10);

    13 v_sql varchar2 (20000);

    14 v_sql_1 varchar2 (10000): = q']

    15 select distinct au.first_name, au.last_name,.

    16: v_table_name table_name, lab_code

    Lab 17 l

    18 join aus app_user_security on AUS.owning_lab_id = l.lab_id

    19 join app_user AU AU. APP_USER_ID = AUS. Join APP_USER]';

    20 v_sql_2 varchar2 (10000): = q'[t on (t.ADDED_BY = to THE.)] APP_USER_ID

    21 or t.last_modified_by = au.app_user_id)

    22 where lab_locale = 'en_AU '.

    23 and (t.added_date > to_date (: v_startday, "MM/DD/YYYY"))

    24 or t.last_modified_date > to_date (: v_startday, "MM/DD/YYYY"))

    25 order by last_name, first_name

    26     ]';

    start 27

    28 n: = 0;

    29 because me to (select table_name from all_tables where owner = v_owner order of table_name)

    loop 30

    31 v_table_name: = substr (i.table_name, 1, instr (i.table_name, '_JN') - 1);

    32 - dbms_output.put_line ('v_table_name: ' | v_table_name |'; i.table_name: ' | i.table_name);

    33 v_sql: = v_sql_1 | i.table_name | v_sql_2;

    34 - dbms_output.put_line (v_sql);

    start at 35

    36 open v_cur for v_sql using v_table_name, v_startday, v_startday;

    37 loop

    38 extract v_cur in v_first_name, v_last_name, v_out_tab, v_lab_code;

    39 exit when v_cur % NOTFOUND;

    40               n := n + 1;

    41 v_audit_tab.extend;

    42 v_audit_tab (n): = audit_type (v_first_name, v_last_name, v_out_tab, v_lab_code);

    43 end loop;

    44 close v_cur;

    45 emergency

    46 then than others then

    then 47 cases sqlcode = - 1030 - insufficient privileges

    48 dbms_output.put_line (' no privs to ' |) THE USER | "on" | i.table_name);

    49 exit;

    50 end if;

    51 end;

    52 end loop;

    53 x in (select * from table (v_audit_tab))

    loop 54

    55 dbms_output.put_line (x.first_name |) «, » || x.last_name | ',' | x.table_name | ',' | x.lab_code);

    loop end 56;

    end 57;

    58.

    PL/SQL procedure successfully completed.

    Issue in this case, developer you can't find any (results) output as expected after the execution of this procedure, so is there something wrong?

    Thank you very much.

    When you try this below is query it returns all the lines?

    Select table_name

    from all_tables

    where owner = "SLIMSINTDM."

    order of table_name;

  • NPL of multiple execution for the awr sql_id

    Hi Experts,

    NPL of multiple execution for the AWR sql_id,

    I followed questions

    1. What plan using opimizer tcurrently?
    2. make sure optimizer to choose good plans


    SQL > select * from table (dbms_xplan.display_awr ('fb0p0xv370vmb'));

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID fb0p0xv370vmb
    --------------------

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 417907468

    ---------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time |
    ---------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 63353 (100) |
    | 1. UPDATE |
    | 2. SORT ORDER BY | 17133. 2978K | 3136K | 63353 (1) | 00:14:47 |
    | 3. HASH JOIN RIGHT SEMI | 17133. 2978K | 62933 (1) | 00:14:42 |
    | 4. COLLECTION ITERATOR PICKLER FETCH | |
    | 5. HASH JOIN RIGHT SEMI | 68530 | 11 M | 62897 (1) | 00:14:41 |

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | 6. VIEW | VW_NSO_1 | 5000 | 35000 | 33087 (1) | 00:07:44 |
    | 7. COUNTY STOPKEY |
    | 8. VIEW | 127K | 868K | 33087 (1) | 00:07:44 |
    | 9. GROUP SORT BY STOPKEY | 127K | 2233K | 46 M | 33087 (1) | 00:07:44 |
    | 10. TABLE ACCESS FULL | ASYNCH_REQUEST | 1741K | 29 M | 29795 (1) | 00:06:58 |
    | 11. TABLE ACCESS FULL | ASYNCH_REQUEST | 1741K | 280 M | 29801 (1) | 00:06:58 |
    ---------------------------------------------------------------------------------------------------------------

    SQL_ID fb0p0xv370vmb
    --------------------
    SELECT ASYNCH_REQUEST_ID, REQUEST_STATUS, REQUEST_TYPE, REQUEST_DATA, PRIORITY, SUBMIT_BY, SUBMIT_DATE.

    Hash value of plan: 2912273206

    --------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time |

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 45078 (100) |
    | 1. UPDATE |
    | 2. SORT ORDER BY | 1323. 257K | 45078 (1) | 00:10:32 |
    | 3. TABLE ACCESS BY INDEX ROWID | ASYNCH_REQUEST | 1. 190. 3 (0) | 00:00:01 |
    | 4. NESTED LOOPS | 1323. 257K | 45077 (1) | 00:10:32 |
    | 5. THE CARTESIAN MERGE JOIN. 5000 | 45000 | 30069 (1) | 00:07:01 |
    | 6. UNIQUE FATE |
    | 7. COLLECTION ITERATOR PICKLER FETCH | |
    | 8. KIND OF BUFFER. 5000 | 35000 | 30034 (1) | 00:07:01 |
    | 9. VIEW | VW_NSO_1 | 5000 | 35000 | 30033 (1) | 00:07:01 |

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | 10. UNIQUE FATE | 5000 | 35000 |
    | 11. COUNTY STOPKEY |
    | 12. VIEW | 81330 | 555K | 30033 (1) | 00:07:01 |
    | 13. GROUP SORT BY STOPKEY | 81330 | 1 429 K | 2384K | 30033 (1) | 00:07:01 |
    | 14. TABLE ACCESS FULL | ASYNCH_REQUEST | 86092 | 1513K | 29731 (1) | 00:06:57 |
    | 15. INDEX RANGE SCAN | ASYNCH_REQUEST_SUB_IDX | 1 | | | 1 (0) | 00:00:01 |
    --------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 3618200564

    --------------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time |

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 59630 (100) |
    | 1. UPDATE |
    | 2. SORT ORDER BY | 4474 | 777K | 59630 (1) | 00:13:55 |
    | 3. HASH JOIN RIGHT SEMI | 4474 | 777K | 59629 (1) | 00:13:55 |
    | 4. VIEW | VW_NSO_1 | 5000 | 35000 | 30450 (1) | 00:07:07 |
    | 5. COUNTY STOPKEY |
    | 6. VIEW | 79526 | 543K | 30450 (1) | 00:07:07 |
    | 7. GROUP SORT BY STOPKEY | 79526 | 1397K | 7824K | 30450 (1) | 00:07:07 |
    | 8. TABLE ACCESS FULL | ASYNCH_REQUEST | 284K | 5003K | 29804 (1) | 00:06:58 |
    | 9. TABLE ACCESS BY INDEX ROWID | ASYNCH_REQUEST | 71156 | 11 M | 29141 (1) | 00:06:48 |

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | 10. NESTED LOOPS | 71156 | 11 M | 29177 (1) | 00:06:49 |
    | 11. UNIQUE FATE |
    | 12. COLLECTION ITERATOR PICKLER FETCH | |
    | 13. INDEX RANGE SCAN | ASYNCH_REQUEST_EFFECTIVE_IDX | 327K | | 392 (1) | 00:00:06 |
    --------------------------------------------------------------------------------------------------------------------------------

    Thank you
    -Raj

    Published by: tt0008 on August 22, 2012 20:34

    Hello

    (1) you can see what plan has been used lately by running this query:

    select begin_interval_time, plan_hash_value
    from dba_hist_sqlstat st,
            dba_hist_snapshot sn
    where st.snap_id = sn.snap_id
    and sql_id = 'fb0p0xv370vmb'
    order by begin_interval_time desc;
    

    However, there is no guarantee that the next time you run this query, the latest plan will be chosen.
    Periodically, the plan is regenerated (for example when new statistics are collected, is the structure of a table referenced in)
    the query is changed etc.), and you can get 4 plans, or even a new function of many factors
    (statistics, bind variable values, the optimizer, NLS etc settings settings.)

    (2) this question is too large for the answer to fit into a thread, there are books written on the subject. The short answer is:
    If you know which of the 4 plans is right for you, then you can use a stored outline to lock in (it seems that you are not on 11g so SQL Profiler are not an option for you).
    Or you can try to find out why the optimizer generates different plans and address the underlying issue (the most common reason is to bind peeking - but to say
    course, we need to know more, starting with the text of your query).

    Best regards
    Nikolai

  • Error, while the creation and execution of stored procedure

    Hello

    I'm creating a procedure stored and discovered during the compilation and execution of procedure.

    CREATE OR REPLACE PROCEDURE procTEST
    AS
    BEGIN
    WITH
    AS Report1
    (
    SELECT * FROM Employee
    )

    SELECT * FROM REPORT1

    END;
    /

    ERROR when compiling

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

    PROCTEST update procedure

    Errors: Newspaper the compiler check

    ERROR when executing

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

    PROCTEST update procedure

    Errors: Newspaper the compiler check
    Error from line: 15 command.
    EXEC procTEST
    Error report-
    ORA-06550: line 1, column 7:
    PLS-00905: object SYSTEM. PROCTEST is not valid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    06550 00000 - "line %s, column % s:\n%s".
    * Cause: Usually a PL/SQL compilation error.
    * Action:

    Hello

    user13360241 wrote:

    I want to insert values into the table tmpemployees.

    Insert into tmpemployees

    Select * from Report1

    CREATE OR REPLACE PROCEDURE procTEST
    AS
    BEGIN
    WITH
    AS Report1
    (
    SELECT * FROM Employee
    )

    Insert into tmpemployees

    SELECT * FROM REPORT1

    END;
    /

    I see.  Then, there is no need to use the PL/SQL.  All you need is:

    INSERT INTO tempemployees

    SELECT *.

    OF REPORT1.

    (assuming that the columns match Report1 tempemployees... It is best to explicitly list the individual columns, like this:

    INSERT INTO tempemployees (employyee_id, first_name,...)

    SELECT (col_1, col_2,...)

    OF REPORT1.

    )

    If you need to use the PL/SQL for a reason, you could use the exact same INSERT statement in PL/SQL:

    CREATE OR REPLACE PROCEDURE proctest

    AS

    BEGIN

    INSERT INTO tempemployees (employyee_id, first_name,...)

    SELECT (col_1, col_2,...)

    OF REPORT1.

    END proctest;

    /

    DISPLAY ERRORS

  • How to find the last time that the execution of the procedure and by whom?

    Hi all

    Can be found as the last run and the procedure by which the user in the dictionary of data or something else?

    Thanks in advance.

    At least that audit you, you can probably not.

    If the goal is a particular stored procedure, you can maintain a work table so he can follow the execution time, audit owner etc.

    Concerning

    Biju

  • Execution of a procedure

    I have a procedure named format_it (10.33).
    How should I call it environments such as sql * more sql or plu or command prompt.
    When and where to use CALL format_it (10.33) and when and where to use execute format_it (10.33)

    PL/SQL code should be called (called) with the help of an anonymous PL/SQL block. For example, it is an anonymous block in a procedure called DoSomething (without parameters).

    begin
      DoSomething;
    end;
    

    This block must be created by the customer and passed to Oracle as the client will pass a SQL for Oracle.

    As a SQL statement, an anonymous block can also contain variables bind. The client will then bind values to these variables before execution of the PL/SQL code. E.g. call procedure FunkFoo which expects 2 parameters:

    begin
      FunkyFoo( param1 => :BindVar1, param2 => :BindVar2 );
    end;
    

    To simply test the proc, the customer can also pass literal values rather than (correctly) use bind variables:

    begin
      FunkyFoo( param1 => 123, param2 => 'Hello World!' );
    end;
    

    Some customers, such as SQL * Plus has its own control customer to define. In SQL * Plus, such a client command is EXEC - and this can be used to execute the PL/SQL code. Dynamically, this sales order automatically creates an anonymous PL/SQL block and encapsulates the content will be executed in a statement BEGIN and END; before you submit to Oracle.

  • Execution of the procedure of Oracle APEX

    Hello

    I've written a procedure ' create or replace PROCEDURE process_csvfile (p_filename IN VARCHAR2); " et I want to execute this procedure to Oracle Apex.


    PROCEDURE:

    create or replace PROCEDURE process_csvfile(p_filename IN VARCHAR2)
    AS
    statement1 varchar2(1000);
    statement2 varchar2(1000);
    statement3 varchar2(1000);
    
    begin
    dbms_output.put_Line(p_filename );
    statement1:= 'alter table adb.external_bcc_test location ( '  ||chr(39)|| p_filename||chr(39)|| ')' ;
    dbms_output.put_line(statement1);
    EXECUTE immediate statement1;
    dbms_output.put_line('statement1-> completed');
    EXECUTE immediate 'truncate table ADB.ADB_BCC_TEST';
    dbms_output.put_line('statement2-> completed');
    statement3:='insert /*+ append */ into ADB.ADB_BCC_TEST(BCC_ID,BCC_ADD,"NO_OF_BCC(GEO)") select * from adb.external_BCC_test';
    dbms_output.put_line(statement3);
    EXECUTE immediate statement3;
    dbms_output.put_line('statement3 insert-> completed');
    
    EXCEPTION
    WHEN OTHERS
    then
    raise;
    END;
    
    

    I created the button and the action as a dynamic Action where I wrote below PL/SQ as dynamic Action to perform this procedure


    BEGIN
    
    process_csvfile;
    END;
    
    


    But I get an error" " " ORA-06550: line 4, column 3: PLS-00306: wrong number or types of arguments in the call to 'PROCESS_CSVFILE' ORA-06550: line 4, column 3: PL/SQL: statement ignored (go to error) "

    Oracle Apex Version: 4.2.1

    Thank you

    BO.

    BO123 wrote:

    I've written a procedure ' create or replace PROCEDURE process_csvfile (p_filename IN VARCHAR2); " and I want to run this procedure from Oracle Apex.

    1. create or replace PROCEDURE process_csvfile (p_filename IN VARCHAR2)
    2. AS
    3. statement1 varchar2 (1000);
    4. statement2 varchar2 (1000);
    5. statement3 varchar2 (1000);
    6. Start
    7. dbms_output.put_Line (p_filename);
    8. statement1: = ' change the location of the table adb.external_bcc_test (' |) Chr (39) | p_filename | Chr (39) | ')' ;
    9. dbms_output.put_line (statement1);
    10. EXECUTE immediate statement1;
    11. dbms_output.put_line ('end statement1->');
    12. EXECUTE immediate ' truncate table ADB. ADB_BCC_TEST';
    13. dbms_output.put_line ('end of reporting2->');
    14. statement3: = "insert / * + append * / into ADB." ADB_BCC_TEST (BCC_ID, BCC_ADD, ' NO_OF_BCC (GEO) ') select * from adb.external_BCC_test';
    15. dbms_output.put_line (statement3);
    16. EXECUTE immediate statement3;
    17. dbms_output.put_line ('end statement3 insertion->');
    18. EXCEPTION
    19. WHILE OTHERS
    20. then
    21. lift;
    22. END;

    The treatment is an external table. How to get the source file in the specified location?

    dbms_output.put_linethe instrumentation is unnecessary in an environment of APEX (unless the apex_debug.log_dbms_output method has been called). Use apex_debug API methods instead so that information is available in debug mode.

    There is no reason to use dynamic SQL statements in lines 15-17.

    Creating a column named "NO_OF_BCC (GEO)" is not a good idea and is in conflict with the recommendation of the Oracle do not use identifiers in quotes for the names of database objects. This objects will only cause problems and confusion.

    Lines 20 to 23 are a bug. It doesn't hide where any exception occurred in fact. If there is no specific exception that must be handled in this procedure, it should not contain an exception block.

  • execution of stored procedure in sql developer/sql more with a table setting?

    Hello

    I create a package with a procedure which has a cursor ref as output and a type as an input parameter.  Here is my definition of the package

    PACKAGE 
    -------
    CREATE OR REPLACE PACKAGE TEST
    As
      TYPE RefCursorType IS REF CURSOR;
      type intTableType is table of varchar2(50) index by binary_integer;
      
      PROCEDURE GETDATA (
              P_RECORDS OUT RefCursorType,           
               YEAR_LIST IN intTableType
      );  
    END;
    
    
    PACKAGE BODY
    -----------------------
    
    SET DEFINE OFF
    CREATE OR REPLACE PACKAGE BODY TEST
    AS 
    PROCEDURE GETDATA
    (
      P_RECORDS OUT RefCursorType,  
      YEAR_LIST IN intTableType  
    )
    AS 
    iYearList  IDTableType;
    BEGIN 
      --GET ARRAY COUNT
      IYEARLIST := IDTABLETYPE();
      IYEARLIST.EXTEND(YEAR_LIST.COUNT);
      
      --LOOP THROUGH LISTS AND POPULATE ARRAY
      FOR I IN YEAR_LIST.FIRST .. YEAR_LIST.LAST
      LOOP
      IYEARLIST(I) := IDTYPE(TO_CHAR(YEAR_LIST(I)));
      END LOOP;
      
       OPEN P_RECORDS FOR 
       SELECT CITHTML AS FORMATTED
        FROM dbTest.FORMATTED_HTML
      WHERE YEAR IN (SELECT * FROM TABLE(IYEARLIST))
      ;
      END GETDATA ;
    END TEST ;
    /
    
    

    I want to perform this procedure from the sql or sql developer more to see if it works properly.   The year field dbTest.FORMATTED_HTML is defined as varchar2 (20 bytes).  He has many years as well as text.

    I've used this in the past with simple stored procedures, but not those with a table setting

    var r refcursor;

    exec GETOLDDATA(:r,40);

    print r;

    How can I modify this to allow him to run my stored procedure?

    Thank you

    Just declare SQL, not type of PL/SQL:

    CREATE OR REPLACE

    TYPE Str50TblType

    AS THE TABLE OF THE VARCHAR2 (50)

    /

    CREATE OR REPLACE

    THE TEST PACKAGE

    IS

    GETDATA PROCEDURE)

    P_RECORDS ON SYS_REFCURSOR,

    YEAR_LIST IN Str50TblType

    );

    END;

    /

    CREATE OR REPLACE

    TEST OF PACKAGE BODY

    IS

    GETDATA PROCEDURE)

    P_RECORDS ON SYS_REFCURSOR,

    YEAR_LIST IN Str50TblType

    )

    IS

    BEGIN

    OPEN P_RECORDS

    FOR

    SELECT CITHTML AS FORMATTED

    OF dbTest.FORMATTED_HTML

    WHERE YEAR IN)

    SELECT *.

    TABLE (YEAR_LIST)

    );

    GETDATA END;

    END TEST;

    /

    SY.

  • execution of the procedure with refcursor as output parameter

    Hi I have the package following a procedure with parameter as refcursor OUT.
    Here is an example of sample with the same structure with name in the other table, handling exceptions in my dev environment
    CREATE OR REPLACE PACKAGE TEST_PACK
      IS
    Type refCursor  is  REF CURSOR;
    PROCEDURE TEST_PROC (out_data out refCursor);
    END;
    
    
    CREATE OR REPLACE PACKAGE BODY TEST_PACK 
     IS
     Procedure test_proc (
            out_data out refCursor
                ) is
        --
        v_sql varchar2(4000);
       
        --
        begin
    
               v_sql := 'select
                        * from emp';
                       
            DBMS_OUTPUT.PUT_LINE ( 'Select Query is: '||v_sql );
    
            open out_data for v_sql;
    
            Exception
                when others then
                    DBMS_OUTPUT.PUT_LINE ( 'Error '|| SQLCODE ||','||SQLERRM );
    
       END;   
    end ;
    When I try to execute this procedure with the followig block
    DECLARE
       TYPE my_newcursor IS REF CURSOR;
       test_cur   my_newcursor;
      out_text      VARCHAR2 (4000);
    BEGIN
       TEST_PACK.test_proc(TEST_CUR) ;
       LOOP
          FETCH test_cur INTO out_text;    
          EXIT WHEN test_cur%NOTFOUND;
          dbms_output.put_line('Value of refcur is:'||out_text);
       END LOOP;
         CLOSE test_cur;  
    END;
    I get the following error
    ORA-00932: inconsistent datatypes: expected - got -
    ORA-06512: at line 8
    Could you please help me where I am doing wrong

    Thank you

    You must extract your data to an appropriate data type.

    (and note there is no need to declare your own ref cursor type as Oracle provides sys_refcursor at the end)

    for example

    SQL> set serverout on
    SQL>
    SQL> create or replace procedure test_proc(out_data out sys_refcursor) is
      2    v_sql varchar2(4000);
      3  begin
      4    v_sql := 'select * from emp';
      5    DBMS_OUTPUT.PUT_LINE ( 'Select Query is: '||v_sql );
      6    open out_data for v_sql;
      7  end;
      8  /
    
    Procedure created.
    
    SQL>
    SQL> declare
      2    rc     sys_refcursor;
      3    empRec emp%rowtype;
      4  begin
      5    test_proc(rc);
      6    loop
      7      fetch rc into empRec;
      8      exit when rc%notfound;
      9      dbms_output.put_line('Employee: '||empRec.empno||' - '||empRec.ename);
     10    end loop;
     11    close rc;
     12  end;
     13  /
    Select Query is: select * from emp
    Employee: 7369 - SMITH
    Employee: 7499 - ALLEN
    Employee: 7521 - WARD
    Employee: 7566 - JONES
    Employee: 7654 - MARTIN
    Employee: 7698 - BLAKE
    Employee: 7782 - CLARK
    Employee: 7788 - SCOTT
    Employee: 7839 - KING
    Employee: 7844 - TURNER
    Employee: 7876 - ADAMS
    Employee: 7900 - JAMES
    Employee: 7902 - FORD
    Employee: 7934 - MILLER
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    Why do you use a slider ref anyway?

    {: identifier of the thread = 886365}

  • How to call the output parameter during the execution of a procedure

    Hello

    I wrote a small procedure using parameter, how can I call this procedure?

    exec prc_TABLE('emp',1)

    I tried prc_TABLE ('emp') that the two do not work?

    Any help would be appretiated.
    create or replace procedure  prc_TABLE (str in varchar2,
                                   CODE  OUT number
                                                   )   
    
    Begin
    
         CODE := 1;     
    
         DBMS_OUTPUT.PUT_LINE(code);
         
    end;
    
    /
    Zaid

    >
    I wrote a small procedure using parameter, how can I call this procedure?
    >
    You can not call SQL - if that's what you are wanting to do. You can only call functions of SQL, and these functions cannot have OUT parameters.

  • Execution of the procedure-

    Hello

    Could you tell me how to run a procedure that lies under different scheme serve in a schema to another without mentioning the name of schema before the procedure every time?


    Below is the code in the right way, say, if there are two schemas, test1 and test2 and I want the procedure in Test2 will run under the Test1 schema?

    Connect to test2 schema and grant permission to run for test1
    grant exec on test2.prc to test1; 

    create a public synonym for procedure... with execute privilege...

    so that you can use wth on the schema name.

  • Error during execution of the procedure

    Hello

    This is my procedure,

    create or replace
    PROCEDURE PRC_PARSE_XML (P_XML, CLOB,
    P_XPATH VARCHAR2,
    P_LIST ON PKG_SAM. REF_CURSOR_TYPE)
    IS

    CURSOR C_COLUMNS IS
    SELECT * FROM
    (SELECT ".") / SubLedgerKey' PASS,'VARCHAR2 (20)' the DOUBLE DATATYPE
    UNION ALL
    SELECT '. (/ SubLedgerFlag' PASS,'VARCHAR2 (20)' THE DOUBLE DATATYPE);

    LC_SQL VARCHAR2 (4000);
    LC_COL VARCHAR2 (1000);
    LC_COL_1 VARCHAR2 (1000);
    LC_PASS VARCHAR2 (1000);
    LC_PASS_1 VARCHAR2 (1000);
    LC_QUERY VARCHAR2 (4000);
    BEGIN

    C_COLUMNS J
    LOOP
    LC_COL: = "XTAB." | REPLACE(J.COL,'./');
    IF LC_COL_1 IS NULL THEN
    LC_COL_1: = LC_COL;
    ON THE OTHER
    LC_COL_1: = LC_COL_1 | «, » || LC_COL;
    END IF;
    LC_COL: = NULL;
    END LOOP;

    C_COLUMNS J
    LOOP
    LC_PASS: = REPLACE(J.COL,'./'). » '|| J.DATATYPE |' PATH ' | CHR (39) | J.COL | CHR (39);
    IF LC_PASS_1 IS NULL THEN
    LC_PASS_1: = LC_PASS;
    ON THE OTHER
    LC_PASS_1: = LC_PASS_1 | «, » || LC_PASS;
    END IF;
    LC_PASS: = NULL;
    END LOOP;

    LC_SQL: = 'SELECT'. LC_COL_1 | CHR (10) |
    ' FROM (select xmltype('||) CHR (39) | P_XML | CHR (39) |') double x) you. CHR (10) |
    ', xmltable('||) CHR (39) | P_XPATH | CHR (39) | CHR (10) |
    "in passing t.x' | CHR (10) |
    "COLUMNS". LC_PASS_1 | CHR (10) |
    ') XTAB;';

    LC_QUERY: = 'P_LIST OPEN FOR' | CHR (10) | LC_SQL;
    -P_LIST: = LC_QUERY; IMMEDIATELY RUN LC_QUERY;

    / * EXCEPTION
    WHILE OTHERS THEN
    RAISE_APPLICATION_ERROR (-20001,'PRC_PARSE_XML_DOCUMENT:-' |) SQLERRM) ;*/

    END PRC_PARSE_XML;

    Note:
    P_LIST ON PKG_SAM. REF_CURSOR_TYPE is a ref cursor,

    If I run the above procedure it displays error,.

    DECLARE
    P_LIST PKG_SAM. REF_CURSOR_TYPE;
    BEGIN
    PRC_PARSE_XML ("< SubLedgerList >
    < subledger >
    < SubLedgerKey > 101 < / SubLedgerKey >
    < SubLedgerFlag > Y < / SubLedgerFlag >
    < / subledger >
    < subledger >
    < SubLedgerKey > 102 < / SubLedgerKey >
    < SubLedgerFlag > Y < / SubLedgerFlag >
    < / subledger >
    < subledger >
    < SubLedgerKey > 103 < / SubLedgerKey >
    < SubLedgerFlag > N < / SubLedgerFlag >
    < / subledger >
    < / SubLedgerList > «,» (/ SubLedgerList/large auxiliary book ', P_LIST);

    END;


    Error report:
    ORA-00900: invalid SQL statement
    ORA-06512: at "SHIPLUS_PUB. PKG_XML_PARSER', line 253
    ORA-06512: at line 4 level
    00900 00000 - "invalid SQL statement.


    Kind regards
    Fame

    Published by: fame on 9 may 2012 12:27
  • Execution of a procedure in a package

    Hello

    How to run a procedure in a package? Here is the package

    CREATE OR REPLACE PACKAGE BODY POPULATE_GLTD_TABLES
    IS
    -LOCAL VARIABLES
    VARCHAR2 (10) val1;
    -Create work items:
    v_job1_str VARCHAR2 (4000);
    v_job1 XXMCK. XXMCK_JOB_OT;

    PROCEDURE populate_gltd_tabs1
    IS
    BEGIN
    dbms_output.put_line ('Get_status = > v_job1: ');
    val1: = F_CHECK_GLTD_RECORD_EXISTS ('MCK_GLTD_1');
    IF Val1! s ="THEN
    --
    -Understand the value of details message - TRUE if yes and FALSE if no
    --
    xxmck.mck_write_log_msg.set_msg_tail (true);
    --
    xxmck.mck_write_log_msg.purge('GLTD-TASK1');
    --
    -together framework will define the source so that inserts data into the table of output cont
    --
    xxmck.mck_write_log_msg.set_Context(v_parent_program,v_prog_desc,'GLTD-TASK1');
    --
    xxmck.mck_write_log_msg.log (v_parent_program, "enter in LOAD_GLTD_TABLES.populate_gltd_tabs1', 'prg', 'GLTD-TASK1', 1");
    --
    xxmck.mck_write_log_msg.log_tail (v_parent_program, "enter in LOAD_GLTD_TABLES.populate_gltd_tabs1', 'prg', 'GLTD-TASK1'");
    --

    v_job1_str: = ' XXCOGNOS. LOAD_GLTD_TABLES.populate_gltd_tabs1;';

    v_job1: = NEW XXMCK. XXMCK_JOB_OT ('GLTD-TASK1', v_job1_str, ' test of substantive work: LOAD_GLTD_TABLES.populate_gltd_tabs1 ', INTERVAL ' 60' SECOND ');
    v_job1. PRINT(); -Display of the basic information about the work
    v_job1. SUBMIT(); -Propose in the background
    v_job1. WAIT();
    v_job1. PRINT();
    v_job1.get_Status (v_code, v_message);
    dbms_output.put_line ('Get_status = > v_job1: ' | v_code |) ':' || v_message);

    -SELECT DECODE (cont_exit, 'cont', 'cont', 'err', 'err', 'cont') IN v_result of MCK_LOG_CONT_EXIT_CHK WHERE source = 'GLTD-TASK1;

    -IF v_result = "err" THEN
    -raise_application_error ("-20000, ' program Aborted");
    -END IF;
    END IF;
    EXCEPTION
    WHEN OTHER THEN NULL;
    END populate_gltd_tabs1;

    PROCEDURE mainproc
    IS
    BEGIN
    populate_gltd_tabs1; -CALL to FILL in mck_gltd_1 TABLE
    --
    -Mailing
    --
    xxmck.mck_write_log_msg.send_mail (p_source_prg = > v_parent_program)
    , p_source = > 'GLTD-TASK1.
    , p_msg_type = > 'prg '.
    , p_from = > '[email protected] '.
    , p_to = > '[email protected] '.
    , p_server = > 'mailhub.mckinsey.com '.
    );
    EXCEPTION
    WHEN OTHER THEN NULL;
    END mainproc;

    END POPULATE_GLTD_TABLES;
    /





    And here's my anonymous block to run above package

    BEGIN
    POPULATE_MCK_GLTDFILE.mainproc;
    EXCEPTION - begin exception handler
    WHEN OTHER THEN NULL;
    END;


    I am trying to run above the code into a toad. But I get the error message like: identifier 'POPULATE_MCK_GLTDFILE.mainproc' must be declared.
    There is no parameter to pass.
    The package is compiled successfully.
    I think this must be the easiest question anyone I can ask, but I can't understand the solution.

    Help, please
    Aditya

    Try this (you are using the wromg package name)

    BEGIN
    POPULATE_GLTD_TABLES.mainproc;
    EXCEPTION
    WHEN OTHER THEN NULL;
    END;

    Published by: Saran on January 13, 2012 01:38

    Published by: Saran on January 13, 2012 01:38

    Published by: Saran on January 13, 2012 01:40

  • 403 Forbidden error of execution of the procedures of the URL of the browser stored

    I am currently trying to run a simple stored procedure (ea.hello_world, where "ea" is the pattern and "hello_world" is the name of the procedure) a URL from the browser, but am getting a 403 Forbidden - error message "you don't have permission to access /pls/apex/ea.hello_world on this server. I use APEX 3.2 with Oracle 11 g and mod_plsql and gave the steps of apex_public_user. Any thoughts on what I am doing wrong?

    Here is the process I have used so far:

    Create the "Hello_World" procedure in the "EA: schema

    create or replace
    procedure hello_world
    is
    Start
    HTP. Print ("'Hello World!");
    end;

    I then successfully granted to run the apex_public_user procedure:

    Grant execute on ea.hello_world to apex_public_user;

    Then, I tried to call the stored procedure from the browser using the following syntax:

    http:// < Server >: < port > / pls/apex/< schema >. < Procedure & gt;

    I also experimented with the use of a public synonym and the configuration of the wwv_flow_epg_include_mod_local, but I do not think that the function s relevant since I'm using mod_plsql and not the embedded pl/sql gateway.

    Hello

    If you have below the line in dads.conf, then wwv_flow_epg_include_mod_local sets

    PlsqlRequestValidationFunction wwv_flow_epg_include_modules.authorize
    

    Try:
    Create public synonym

    CREATE PUBLIC SYNONYM hello_world FOR ea.hello_world;
    

    Grant privilege to execute procedure to the public

    GRANT execute on hello_world to public;
    

    Then change the APEX_030200.wwv_flow_epg_include_mod_local function

    CREATE OR REPLACE FUNCTION
    APEX_030200.wwv_flow_epg_include_mod_local(
        PROCEDURE_NAME IN VARCHAR2)
    RETURN BOOLEAN
    IS
    BEGIN  
    
        IF UPPER(procedure_name) IN (
              UPPER('hello_world'))
       THEN
            RETURN TRUE;
        ELSE
            RETURN FALSE;
        END IF;
    END;
    /
    

    Then try
    http://:/pls/apex/hello_world

    If you can now run your procedure in URL, you can then low and e.g. grant execute procedure to the user of DAD.

    Kind regards
    Jari

    http://dbswh.webhop.NET/dbswh/f?p=blog:Home:0

    Published by: jarola on December 6, 2011 16:20

    Published by: jarola on December 6, 2011 16:24

    typo in the name of the function

Maybe you are looking for