simultaneous immediate execution of multiple instructions?

are there techniques to call execute immediate instructions so that they could run simultaneously without waiting than the previous ones (can be different "background", in sessions but at the same time)?

for example if I write:
declare
  stmt_1 varchar2(100) := 'update ... 1 .. ';
  stmt_2 varchar2(100) := 'update ... 2 .. ';
  ...
  stmt_n varchar2(100) := 'update ... n .. ';
begin
  execute immediate stmt_1;
  execute immediate stmt_2;
  ...
  execute immediate stmt_n;
end;
stmt_1 runs first, then stmt_2 and so on. is there a technique to rewrite it so that these statements would be sent for execution without waiting for the other, IE. Here stmt_2 Wouln't expect stmt_1 finish, stmt_3 for stmt_2 etc. I know autonomous operations, but I have no idea if they could be included as well as some other techniques (if any).

I'd appreciate any advice if this scenario can be coded somehow.

Thank you

You can use something like DBMS_SCHEDULER program each of them as to the work to be performed immediately. Schedules would be started one after the other, but each calendar can be made without waiting for the other end.

There is also the DBMS_PARALLEL_EXECUTE (http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_parallel_ex.htm#ARPLS67330) package which is another option.

Tags: Database

Similar Questions

  • The execution of multiple instructions after another

    Guy Helle!

    I was wondering if it is not possible to execute multiple instructions in a line using the Oracle SQL Developer! Impossible to find info on this!

    I have the code as the following statements and about 200:
    INSERT INTO TBL_MATRIX ("Baumart", "9110", "9110.M", "9110.1", "9110.2", "9110.3", "9110.4", "9111", "9130", "9130.M", "9130.1", "9130.2", "9130.3", "9130.4", "9131", "9140", "9150", "9150.15", "9151", "9152", "9160", "9170", "9180", "9190", "91D0", "91D1", "91D1.3", "91D2", "91D3", "91D4", "91E0", "91E0.A", "91E0.S", "91E0.11", "91E0.12", "91E0.13", "91E0.14", "91E0.15", "91E1", "91E2", "91F0", "91T0", "91U0", "9410", "9410.15", "9420")
    VALUES ('Flaumeiche', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG');
    /
    INSERT INTO TBL_MATRIX ("Baumart", "9110", "9110.M", "9110.1", "9110.2", "9110.3", "9110.4", "9111", "9130", "9130.M", "9130.1", "9130.2", "9130.3", "9130.4", "9131", "9140", "9150", "9150.15", "9151", "9152", "9160", "9170", "9180", "9190", "91D0", "91D1", "91D1.3", "91D2", "91D3", "91D4", "91E0", "91E0.A", "91E0.S", "91E0.11", "91E0.12", "91E0.13", "91E0.14", "91E0.15", "91E1", "91E2", "91F0", "91T0", "91U0", "9410", "9410.15", "9420")
    VALUES ('Wacholder', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'S');
    /
    Instead of running each query individually, there must be a way to each of them running automatically. Same SQL Server has this feature!

    Any advice you can give me?

    Kind regards

    Sebastian

    Hello

    You should ask this to the [SQL Developer Forum | http://forums.oracle.com/forums/forum.jspa?forumID=260].

    Just a quick thought. I think in SQL Dev, you have two options. 1. performance and 2. Run the Script (near the run iconic button).

    Copy all the instructions in the editor and click the iconic run the Script instead of the Run iconic button.

    Arun-

  • SQL dynamic immediate execution

    Hi all

    We have a table where we keep the query that will be executed and using bind variables.

    But im facing some problems when I try to use it in immediate execution.

    guess

    function validate is
    varaux varchar2 (200);
    Start
    for r1 in (select query,
    using_bind
    from table_1) loop
    run immediately r1.query in varaux using r1.using_bind;
    Return varaux;
    end loop;
    Returns a null value.
    end;

    I know that's not the way to do it, but can you give me instructions in the topic...

    Thank you
    Bruna

    Published by: Bruna on January 4, 2013 03:07

    >
    We have a table where we keep the query that will be executed and using bind variables.

    But im facing some problems when I try to use it in immediate execution.
    >
    No - the problems you are experiencing are because your function uses invalid syntax. The problems have NOTHING to do with 'run immediately '. This works for me and no changes have been made to the dynamic part.

    create or replace function fn_validate return varchar2 is
    varaux varchar2(200);
    begin
    for r1 in (select 'select ename from emp where empno = :1' query,
    7369 using_bind from dual) loop
    execute immediate r1.query into varaux using r1.using_bind;
    return varaux;
    end loop;
    return null;
    end; 
    
    declare
     myVar varchar2(200);
    begin
     myVar := fn_validate();
     dbms_output.put_line(myVar);
    end;
    
    SMITH
    
  • HELP-immediate execution in PL/SQL has received the error ORA-00904: invalid identifier

    What is the problem with the following codes from PL/SQL (actually it comes to Oracle Metalink Note: 313175.1):
    ===========
    declare
    cursor c1 is select * from $ semantic;
    v_statement VARCHAR2 (255);
    v_nc number (10);
    v_nt number (10);
    Start
    immediate execution
    "select count (*) from $ semantics" in v_nc;
    immediate execution
    ' select count (distinct s_table_name) of semantics$ "in v_nt;
    dbms_output.put_line
    ('Edit' | v_nc |) 'columns ' | v_nt | "tables");
    to r1 c1 loop
    v_statement: = 'ALTER TABLE ' | R1.s_owner | '.' || R1.s_table_name;
    v_statement: = v_statement | «change (' |)» R1.s_column_name | ' ';
    v_statement: = v_statement | R1.s_data_type | ' (' | r1.s_char_length;)
    v_statement: = v_statement | ' CHAR))';
    immediately run v_statement;
    end loop;
    dbms_output.put_line ('Done');
    end;
    /
    =====
    Executed once the codes as sysdba against 10gr 2 database, I got this error:
    From build to select columns to change
    Editing columns 4428 35249
    declare
    *
    ERROR on line 1:
    ORA-00904: invalid identifier
    ORA-06512: at line 22

    I see nothing wrong with the line of "immediate execution". I appreciate your help!

    Thank you.

    Hello
    Try to print the offending instruction using exception, I used small test cases by changing the pl/sql block, you may need to change to respond to all other types of data in this table.

    CREATE TABLE semantics$
    AS
       SELECT USER AS owner,
              table_name,
              data_type AS s_data_type,
              column_name,
              data_length AS s_char_length
       FROM cols
       WHERE table_name = 'MY_OBJECTS';
    
    DECLARE
       CURSOR c1
       IS
          SELECT *
          FROM semantics$;
    
       v_statement   VARCHAR2 (255);
       v_nc          NUMBER (10);
       v_nt          NUMBER (10);
    BEGIN
       EXECUTE IMMEDIATE 'select count(*) from semantics$' INTO v_nc;
    
       EXECUTE IMMEDIATE 'select count(distinct table_name) from semantics$'
          INTO v_nt;
    
       DBMS_OUTPUT.put_line(   'ALTERing '
                            || v_nc
                            || ' columns in '
                            || v_nt
                            || ' tables');
    
       FOR r1 IN c1
       LOOP
          v_statement   := 'ALTER TABLE ' || r1.owner || '.' || r1.table_name;
          v_statement   := v_statement || ' modify (' || r1.column_name || ' ';
          v_statement   :=
             v_statement || r1.s_data_type || '(' || r1.s_char_length;
    
          IF (r1.s_data_type = 'NUMBER')
          THEN
             v_statement   := v_statement || '))';
          ELSE
             v_statement   := v_statement || ' CHAR))';
          END IF;
    
          DBMS_OUTPUT.put_line (v_statement);
    
          -- EXECUTE IMMEDIATE v_statement;
       END LOOP;
    
       DBMS_OUTPUT.put_line ('Done');
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line ('Statement = ' || v_statement);
          DBMS_OUTPUT.put_line (SUBSTR (SQLERRM, 1, 200));
          RAISE;
    END;
    

    _ Output

    ALTERing 13 columns in 1 tables
    ALTER TABLE MY_OBJECTS modify (OWNER VARCHAR2(30 CHAR))
    ALTER TABLE MY_OBJECTS modify (OBJECT_NAME VARCHAR2(30 CHAR))
    ALTER TABLE MY_OBJECTS modify (SUBOBJECT_NAME VARCHAR2(30 CHAR))
    ALTER TABLE MY_OBJECTS modify (OBJECT_ID NUMBER(22))
    ALTER TABLE MY_OBJECTS modify (DATA_OBJECT_ID NUMBER(22))
    ALTER TABLE MY_OBJECTS modify (OBJECT_TYPE VARCHAR2(19 CHAR))
    ALTER TABLE MY_OBJECTS modify (CREATED DATE(7 CHAR))
    ALTER TABLE MY_OBJECTS modify (LAST_DDL_TIME DATE(7 CHAR))
    ALTER TABLE MY_OBJECTS modify (TIMESTAMP VARCHAR2(19 CHAR))
    ALTER TABLE MY_OBJECTS modify (STATUS VARCHAR2(7 CHAR))
    ALTER TABLE MY_OBJECTS modify (TEMPORARY VARCHAR2(1 CHAR))
    ALTER TABLE MY_OBJECTS modify (GENERATED VARCHAR2(1 CHAR))
    ALTER TABLE MY_OBJECTS modify (SECONDARY VARCHAR2(1 CHAR))
    Done
    

    Concerning

    Published by: OrionNet on January 5, 2009 23:53

    Published by: OrionNet on January 5, 2009 23:55

  • Execution of multiple user profiles does not not in Firefox 32.0.3

    Hello.

    I have several profiles user for work and private use. Today I decided to use Firefox for private use again (currently using Chrome for private use). Because on Chrome, the video is "pixelated" when video quality is superior to 720 p. Also for purposes of stability, if Firefox crashes, which happens frequently, I keep everything.

    In any case, I use the Profile Manager for execution of multiple user profiles.

    The problem is when I try to open a private profile when you're already running a work profile, it opens a new window of work profile, not a private.

    I use this shortcut: "C:\Program Files (x 86) \Mozilla" P - by default - noremote
    The "default" profile is the work, I have a different shortcut, which is private:
    "C:\Program Files (x 86) \Mozilla ' private Pei - noremote

    Any help will be much appreciated. Thank you.

    Hello tgolisa, I think the right command line parameter is -no-remote...

  • Changing table via the package with immediate execution (problem)

    Hello

    I have a unusual problem. I have a package that contains the procedure that via execute immediate statement, creates a table on which he performs different actions for example:

    -alter table some_owner.dummy_table noparallel

    -create index some_owner.idx_name on some_owner.dummy_table (column)...

    But I only managed to run move and create synonym table/public via execute immediate statement. Actions as alter table and create index fails with error ORA-01031: insufficient privileges.

    Note If call these commands outside the package (a simple script) this all done OK.

    I found a way, where I set the AUTHID CURRENT_USER command create package statement. In this way all the actions executed OK.

    I wonder why I can't change the table via the package with immediate execution on a table that is in the tablespace "SOME_TABLESPACE" and the title of owner "SOME_OWNER", without putting the AUTHID command on the package.

    There must be a problem why a package cannot change the table which is owned by the user 'SOME_OWNER '.

    All useful responses would be appreciated.

    I have a unusual problem.

    No - you don't have. This question has been answered SEVERAL times on this forum and others.

    But I only managed to run move and create synonym table/public via execute immediate statement. Actions as alter table and create index fails with error ORA-01031: insufficient privileges.

    OK - your username doesn't have privileges to do these operations or only received privileges through roles.

    Roles are DISABLED in named PL/SQL blocks that use of the AUTHOR's rights.

    Note If call these commands outside the package (a simple script) this all done OK.

    I found a way, where I set the AUTHID CURRENT_USER command create package statement. In this way all the actions executed OK.

    Of course - the roles are NOT disabled in named PL/SQL blocks that use the rights of the APPELLANT or in anonymous blocks.

    I wonder why I can't change the table via the package with immediate execution on a table that is in the tablespace "SOME_TABLESPACE" and the title of owner "SOME_OWNER", without putting the AUTHID command on the package.

    Well now you know!

  • How how to escape double match in immediate execution in the trigger

    Hi all

    Please inform me what is the error in this procedure.
    I think that the problem in the way to escape double match.

    SQL > create or replace procedure P2
    2 is
    3. start
    4 run immediately 'create or replace trigger t2.
    5 |' before insertion '
    6: ' on tb_test'
    7: ' for each row '
    8: ' declare '
    9: ' start '
    * 10 |' immediate execution "create table t1 as select distinct (NVL (soundex (namess),"'NONE "')) test ' *;
    11: ' end; »
    12 end;
    13
    14.

    CAUTION: Procedure created with compilation errors.

    SQL > show error
    Errors of PROCEDURE P2:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    10/83 PLS-00103: encountered the symbol "NONE" when expecting one of
    What follows:
    * & = - + ; <>/ is mod remains not return rem
    return < an exponent (*) > <>or! = or ~ = > = < = <>and or
    as like2 like4 likec between using | Member in bulk
    submultiset

    SQL >

    Hello

    Try the code below:

    create or replace procedure P2
    is
    Start
    run immediately "create or replace trigger t2 before insertion
    on tb_test
    for each line
    declare
    Start
    run immediately "create table t1 as select distinct (NVL (soundex (account_number),"NONE")) of the test";
    end;';
    end;
    /

  • Appeal procedure set up by IMMEDIATE EXECUTION

    SQL> Create table bipul_test (a number(3), b number(2), c number(5), d varchar2(10), status varchar2(10));
    
    Table Created.
    
    SQL> desc bipul_test
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     A                                                  NUMBER(3)
     B                                                  NUMBER(2)
     C                                                  NUMBER(5)
     D                                                  VARCHAR2(10)
     STATUS                                             VARCHAR2(10)
    
    
    SQL> insert into bipul_test values(1,1,1,'a', null);
    SQL> insert into bipul_test values(1,1,1,'b', null);
    SQL> insert into bipul_test values(2,1,2,'c', null);
    SQL> insert into bipul_test values(2,2,2,'d', null);
    SQL> insert into bipul_test values(null, null, null, 'x',null);
    SQL> commit;
    
    SQL> select * from bipul_test;
    
             A          B          C D          STATUS
    ---------- ---------- ---------- ---------- ----------
             1          1          1 a          
             1          1          1 b          
             2          1          2 c          
             2          2          2 d
                                     x
    Package: my_package
    Procedure: proc2, proc3
    CREATE OR REPLACE PACKAGE SRGUPTA.my_package AS
        -- PROCEDURE proc2;
        PROCEDURE proc2 (status OUT varchar2);
        PROCEDURE proc3 (Proc_name IN VARCHAR2, status IN OUT varchar2);
    END my_package;
    
    /
    
    CREATE OR REPLACE PACKAGE BODY SRGUPTA.my_package
    IS
    -- PROCEDURE proc2
    PROCEDURE proc2(status OUT varchar2)
    AS
    n number(2);
       BEGIN
         update bipul_test set status ='SUCCESS' where A=1;
         commit;
         status:='FAILURE';
    end proc2;
    
    PROCEDURE proc3 (proc_name varchar2, status IN OUT varchar2)
    AS
    x varchar2(100):=null;
       BEGIN
         --EXECUTE IMMEDIATE 'BEGIN '||proc_name||'; END;';
         EXECUTE IMMEDIATE 'BEGIN '||proc_name||'(status); END;';
         
         if status='FAILURE' then
            update bipul_test set status ='FAILURE' where A=2;
            commit;
         end if;
    end proc3;
    END  my_package;
    /
    The Code of the appellant:
    set feedback on
    set serveroutput on
    DECLARE status VARCHAR2(100):='';
     begin
    my_package.proc3('my_package.proc2', status);
    end;
    /
    EXIT;
    Without THE normal execution mode param works very well. Above code is an effort through which I tried to capture the value of OUT to the appellant PROC3 param.

    PROC3 call PROC2 with immediate execution. Now if PROC2 have a parameter OUT and I want to capture in PROC3, is it possible?

    Out of desire to my code:
    SQL> select * from bipul_test;
    
             A          B          C D          STATUS
    ---------- ---------- ---------- ---------- ----------
             1          1          1 a          SUCCESS
             1          1          1 b          SUCCESS
             2          1          2 c          FAILURE
             2          2          2 d           FAILURE
                                    x
    Published by: handsome June 3, 2011 06:29
    SQL> Create table bipul_test (a number(3), b number(2), c number(5), d varc
    (10));
    
    Table created.
    
    SQL> insert into bipul_test values(1,1,1,'a', null);
    
    1 row created.
    
    SQL>
    SQL> insert into bipul_test values(1,1,1,'b', null);
    
    1 row created.
    
    SQL> insert into bipul_test values(2,1,2,'c', null);
    
    1 row created.
    
    SQL> insert into bipul_test values(2,2,2,'d', null);
    
    1 row created.
    
    SQL> insert into bipul_test values(null, null, null, 'x',null);
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> select * from bipul_test;
    
             A          B          C D          STATUS
    ---------- ---------- ---------- ---------- ----------
             1          1          1 a
             1          1          1 b
             2          1          2 c
             2          2          2 d
                                     x
    
    SQL> CREATE OR REPLACE PACKAGE my_package AS
      2    -- PROCEDURE proc2;
      3    PROCEDURE proc2(status OUT varchar2);
      4    PROCEDURE proc3(Proc_name IN VARCHAR2, status IN OUT varchar2);
      5  END my_package;
      6  /
    
    Package created.
    
    SQL> CREATE OR REPLACE PACKAGE BODY my_package
      2  IS
      3  -- PROCEDURE proc2
      4  PROCEDURE proc2(status OUT varchar2)
      5  AS
      6  n number(2);
      7     BEGIN
      8   update bipul_test set status ='SUCCESS' where A=1;
      9   commit;
     10   status:='FAILURE';
     11  end proc2;
     12
     13  PROCEDURE proc3 (proc_name varchar2, status IN OUT varchar2)
     14  AS
     15  x varchar2(100):=null;
     16     BEGIN
     17   --EXECUTE IMMEDIATE 'BEGIN '||proc_name||'; END;';
     18   EXECUTE IMMEDIATE 'BEGIN '||proc_name||'(:1); END;' USING IN OUT status;
     19
     20   if status='FAILURE' then
     21      update bipul_test set status ='FAILURE' where A=2;
     22      commit;
     23   end if;
     24  end proc3;
     25  END  my_package;
     26  /
    
    Package body created.
    
    SQL> set serverout on
    SQL> DECLARE
      2  status VARCHAR2(100):='';
      3   begin
      4  my_package.proc3('my_package.proc2', status);
      5  dbms_output.put_line(status);
      6  end;
      7  /
    FAILURE
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • difference btw dbms_sql.execution and immediate execution

    Hello

    IAM using 10g, difference btw immediate.please dbms_sql.execution and execution to tell me.

    797525 wrote:

    IAM using 10g, difference btw immediate.please dbms_sql.execution and execution to tell me.

    SQL all (and all the anonymous PL/SQL blocks) are analyzed by Oracle as a SQL cursors. These cursor structures are stored in the Shared Pool in the SGA (shared memory area which are essentially the "brain" of the database instance).

    Once a cursor was created for a statement SQL, how to use and interface with this SQL cursor on the server (from the point of view of the customer)?

    We use on the client side, a calling interface (or API) that allows our code to interact with this SQL cursor on the server. This interface can be ODBC. Or BDE. Or ADO. Or many other 3-4 letters for database interfaces.

    PL/SQL is also a language of 'customer' from a SQL perspective. Such as Java and c#, the code PL/SQL will be calls to the SQL engine to analyze and create SQL cursors.

    Of course, PL/SQL differs in 2 areas. It runs in the process of the Oracle server. It is the neighbour of the SQL engine.

    For this reason, PL/SQL is much more perfectly integrated with the SQL than Java or c#.

    But even in spite of this integration, you still need an interface in the client (PL/SQL) to interact with the SQL cursor, that you have created. In PL/SQL, there are a number of such interfaces customer.

    There are explicit and implicit cursors. And there are sliders DBMS_SQL and reference. And there are implicit cursors created through immediate enforcement.

    The difference between DBMS_SQL and immediate execution is therefore a difference in customer language interface. The SQL cursor on the server (in the shared Pool) doesn't know what customer interface is used. He cares not.

    Client side, each of these client interfaces to a SQL cursor has a different function. And determines which one to use.

    run immediately , it's fast and easy for dynamic SQL, but it cannot be used to determine the structure (called projection SQL) returned by a cursor to Select . So despite the dynamic SQL code, we must always know the encoding of time, just what this slider will return to consume its production.

    DBMS_SQL to 'describe' the cursor SQL projection. So, we can create a dynamic Select SQL cursor. We can question its interface describe in order to determine the number, names and the data types of the columns returned. It can be removed these column values dynamically and consume the cursor.

    There are therefore a major difference in the two feature sets. Tools for interfacing with the same SQL cursor.

    So the main points to remember are:
    -all SQL liquidation as SQL cursors on the server
    -you have different interfaces in the language of the client to interact with a SQL cursor

    ++

    Your mission as a programmer, if you choose to accept it, is to determine which of these client interfaces is better suited to meet the requirements in your code.

    This message will self-destruct in... 5.4.3 2...

  • Update in immediate execution with rownum

    Can I put in an UPDATE by immediate execution that only maximum 10 lines will be updated?

    It is:
       EXECUTE IMMEDIATE 'UPDATE A_PAZIENTI_ESAMI SET  '||
                        ' NREFERTO      = :1, '|| 
                        ' DATA_REFERTO  = :2, '|| 
                        ' ANNOREFERTO   = :3, '|| 
                        ' DATA_EROGAZ   = :4, '|| 
                        ' STATO_REFERTO = :5, '|| 
                        ' MEDICO_E      = :6  '|| 
                        ' WHERE '|| WHERE_CLAUSE_ESA  
    --
    || ' and rownum <= 10'   -- this is my doubt
    
    --
    
       USING    AP_REFERTOB.NREFERTO,
                        AP_REFERTOB.DATARF, 
                        EXTRACT (YEAR FROM AP_REFERTOB.DATARF) ,
                        AP_REFERTOB.DATAEROGA,
                        STATOREFERTO,
                        AP_REFERTOB.K_MED;
       COMMIT;
    Thanks in advance

    Hello
    your query works very well. It updates only the first 10 rows based on the place where the condition.

    Thank you.

  • sql dynamic and immediate execution

    Hello all;

    Just curious... Why developers are still using dynamic sql... and run immediately, because I always thought that dynamic sql were negative and the use of immediate execution as well...

    or did I miss something...

    I like this white paper on the topic: SQL in PL/SQL
    http://www.Oracle.com/technetwork/database/features/PLSQL/overview/doing-SQL-from-PLSQL-129775.PDF

  • Help debug Execute Immediate on the fly instruction execution

    Hello can you please ideintify wrong in the Sub statement?
    East of Oracle 9i

    DECLARE
    STMT VARCHAR2 (32767).
    BEGIN
    FOR STMT IN
    (
    SELECT 'ANALYZE TABLE' | TABLE_NAME | "PARTITION (P2011M01)'. ' CALCULATE STATISTICS STMT
    OF USER_TAB_PARTITIONS
    WHERE NOM_PARTITION LIKE '% P201.
    TABLE_NAME GROUP
    )
    LOOP
    IMMEDIATELY EXECUTE STMT;
    END LOOP;
    END;
    /


    Error report:
    ORA-06550: line 12, column 19:
    PLS-00382: expression is of the wrong type
    ORA-06550: line 12, column 1:
    PL/SQL: Statement ignored
    06550 00000 - "line %s, column % s:\n%s".
    * Cause: Usually a PL/SQL compilation error.
    * Action:


    Thank you in advance.

    SMTN.SMTN

    .

  • Procedure failed with ORA-01403, associated with immediate execution, captured

    This procedure compiles without error. Its purpose is to copy the sequence of one schema to another object. After it failed with ORA-01403, I added exception code of capture (see the comments in the code).

    A few notes:

    1. I started the proceedings with exec copy_sequence ('ADDRESS_SEQ', 'SST', 'TEST1');

    2. the first sql string is built correctly since I can see in the console output:

    Select last_number in the all_sequences where sequence_owner = upper('TSS') and upper('ADDRESS_SEQ') = sequence_name

    I can run this SQL command, and returns a real value;

    Here is the procedure

    SET SERVEROUTPUT ON;

    create or replace procedure copy_sequence (seq VARCHAR2, prod_schema VARCHAR2, VARCHAR2 test_schema)

    as

    Val number (21);

    s_sql varchar2 (200);

    Start

    s_sql: = ' select last_number in the all_sequences where sequence_owner = upper('''|| prod_schema ||'') ') and sequence_name = upper('''||) Seq | " ')';

    -immediate' select last_number in the Vale of all_sequences where sequence_owner = upper('''|| prod_schema ||'') ') and sequence_name = upper('''||) Seq | " ')';

    Dbms_output.put_line ('sql 1 ' | s_sql);

    execute immediate s_sql in val;  ---!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The code does not work here!

    Dbms_output.put_line ('val' |) Val);

    s_sql: = 'delete the sequence'. test_schema |'. ' || FF.;

    Dbms_output.put_line ('sql 2 ' | s_sql);

    -execution immediate s_sql;

    s_sql: = 'create the sequence'. test_schema |'. ' || Seq |' minvalue maxvalue 1 999999999999999999999 begin by ' | Val | 'increment of 1';

    Dbms_output.put_line ('sql 3 ' | s_sql);

    -execution immediate s_sql;

    -Add the following after procedure thown ORA-01403: no data found

    exception when TOO_MANY_ROWS then DBMS_OUTPUT.put_line ('TOO_MANY_ROWS error');

    When NO_DATA_FOUND then DBMS_OUTPUT.put_line ('error NO_DATA_FOUND');

    While some other then raise_application_error (-20011, "Unknown Exception in this procedure");

    end;

    /

    Hoek wrote:

    The user (no SYSTEM, SYS, and SYSTEM are special, you should not use them unless you have TO) execution of the procedure must have the necessary privileges granted directly, bypassing a role...

    ??? There is nothing special about SYS or SYSTEM in what concerns them stored procedures. SYS by default is granted directly SELECT ANY SEQUENCE, so it does not work for the owner of MS by SYS. SYSTEM is therefore not:

    Scott@pdborcl12 > create sequence s;

    Order of creation.

    Scott@pdborcl12 > create or replace
    2 procedure system.p1
    3 is
    number of v_last_value 4;
    5. start
    6. Select last_number
    7 in v_last_value
    8 of all_sequences
    9 where sequence_owner = 'SCOTT '.
    10 and s = sequence_name ';
    11 end;
    12.

    Created procedure.

    Scott@pdborcl12 > system.p1 exec.
    BEGIN system.p1; END;

    *
    ERROR on line 1:
    ORA-01403: no data found
    ORA-06512: at "SYSTEM. "P1", line 5
    ORA-06512: at line 1

    Scott@pdborcl12 > grant select on s to the system;

    Grant succeeded.

    Scott@pdborcl12 > system.p1 exec.

    PL/SQL procedure successfully completed.

    Scott@pdborcl12 >

    SY.

  • Parallel execution of multiple scripts

    Hi all
    I understand that aid of parallels that we can achieve the parallel execution of the queries(insert/update/delete).
    Question of my today, I would like to know if parallelism can be achieved for the following scenario.

    I have a script with an insert select statement and multiple merge statements and a few updates statements all on the same table.
    I have to run this script 12 times on the same table, once for each month of the year.
    Currently, we run for Jan (where record_date = '201001') commit, then run for February and so on.

    Every 12 months can be executed in parallel. One way I can think is to create 12 different scripts and kicking around the opening 12 sessions SQL more (all on the same table).
    Is there a better way to do this?

    Note: the data for each month will not affect other other data month.

    Kind regards
    AJ

    Creation of 12 different scripts would be a suboptimal solution and a maintenance nightmare. 1 set script and call 12 times with different settings would be a little better.
    1 creating a stored procedure with parameters and execute that procedure in the 12 times Planner would be even better, because everything works on the side server only.

    Your description is deliberately vague, so the possibility of blocking cannot be excluded.

    ----------
    Sybrand Bakker
    Senior Oracle DBA

  • Regd:-immediate execution

    Hello

    WHEN I EXECUTE THE QUERY I get PLSQL /Numeric or the error value. Suggestions are welcome.


    DECLARE
    CURSOR c1
    IS
    SELECT object_name, object_type, owner
    Of object
    WHERE object_type IN ('PACKAGE')
    AND object_name = 'PKG_UPLOAD. '
    AND owner = 'TEST ';

    lv_v_header VARCHAR2 (2000): = ' SELECT DBMS_METADATA. GET_DDL (';)
    lv_v_footer VARCHAR2 (200): = ') FROM DUAL';
    lv_v_object_type all_objects.object_type%TYPE;
    lv_v_object_name all_objects.object_name%TYPE;
    lv_v_owner all_objects.owner%TYPE;
    lv_v_stmt VARCHAR2 (4000);
    lv_v_quotes VARCHAR2 (100): = "';
    lv_v_comma VARCHAR2 (100): = ', ';
    lv_v_value VARCHAR2 (32767).
    fileHandler UTL_FILE.file_type;
    lv_v_file_name VARCHAR2 (3000);
    BEGIN
    I'm IN c1
    LOOP
    BEGIN
    lv_v_file_name: =.
    i.Owner
    || '_'
    || i.object_name
    || CASE
    WHEN i.object_type = "PACKAGE".
    THEN '. PKB'
    WHEN i.object_type = 'TRIGGER '.
    THEN '. TRG'
    END;
    lv_v_object_type: = i.object_type;
    lv_v_object_name: = i.object_name;
    lv_v_owner: = i.owner;
    lv_v_stmt: =.
    lv_v_header
    || lv_v_quotes
    || lv_v_object_type
    || lv_v_quotes
    || lv_v_comma
    || lv_v_quotes
    || lv_v_object_name
    || lv_v_quotes
    || lv_v_comma
    || lv_v_quotes
    || lv_v_owner
    || lv_v_quotes
    || lv_v_footer;

    Lv_v_stmt EXECUTE IMMEDIATE
    IN lv_v_value;

    fileHandler: = UTL_FILE.fopen ("TEST_DIR', lv_v_file_name, 'w');
    UTL_FILE.PUTF (filehandler, lv_v_value |) » \n');
    UTL_FILE.fclose (filehandler);
    END;
    END LOOP;
    END;
    /

    In case you need help to use UTL_FILE, then this is.

    SQL> DECLARE
      2    myddl clob;
      3    fname VARCHAR2(200);
      4    extn VARCHAR2(200);
      5
      6  /* Main function to get the DDls with DBMS_METADATA */
      7    FUNCTION get_metadata(pi_obj_name  dba_objects.object_name%TYPE,
      8                          pi_obj_type  IN dba_objects.object_type%TYPE,
      9                          pi_obj_owner IN dba_objects.owner%TYPE) RETURN clob IS
     10      h   number;
     11      th  number;
     12      doc clob;
     13    BEGIN
     14      h := DBMS_METADATA.open(pi_obj_type);
     15      DBMS_METADATA.set_filter(h, 'SCHEMA', pi_obj_owner);
     16      DBMS_METADATA.set_filter(h, 'NAME', pi_obj_name);
     17      th := DBMS_METADATA.add_transform(h, 'MODIFY');
     18      th := DBMS_METADATA.add_transform(h, 'DDL');
     19      --DBMS_METADATA.set_transform_param(th,'SEGMENT_ATTRIBUTES',false);
     20      doc := DBMS_METADATA.fetch_clob(h);
     21      DBMS_METADATA.CLOSE(h);
     22      RETURN doc;
     23    END get_metadata;
     24
     25  ---Writing the CLOB using UTL_FILE
     26  PROCEDURE write_clob(p_clob in clob, pi_fname VARCHAR2) as
     27      l_offset number default 1;
     28      fhandle UTL_FILE.file_type;
     29      buffer VARCHAR2(4000);
     30    BEGIN
     31      fhandle:=UTL_FILE.fopen('SAUBHIK',pi_fname,'A');
     32      loop
     33        exit when l_offset > dbms_lob.getlength(p_clob);
     34        buffer:=dbms_lob.substr(p_clob, 255, l_offset);
     35        UTL_FILE.put_line(fhandle,buffer);
     36        l_offset := l_offset + 255;
     37        buffer:=NULL;
     38      end loop;
     39      UTL_FILE.fclose(fhandle);
     40    END write_clob;
     41
     42  ---Main execution begins.
     43  BEGIN
     44    FOR i in (SELECT object_name, object_type, owner
     45                FROM dba_objects
     46               WHERE owner IN ('SCOTT', 'HR')
     47                 AND object_type IN ('PACKAGE', 'TRIGGER')) LOOP
     48      --Calling the function.
     49      myddl := get_metadata(i.object_name,i.object_type,i.owner);
     50      --Preparing the filename.
     51      fname := i.owner||i.object_name || '.' ||
     52               CASE WHEN i.object_type='PACKAGE' THEN 'pkb'
     53               ELSE 'trg'
     54               END;
     55     --Writing the file using UTL_FILE.
     56      write_clob(myddl,fname);
     57    END LOOP;
     58  END;
     59  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    also, about your mistake, "EXECUTE IMMEDIATE lv_v_stmt INTO lv_v_value; DBMS_METADATA.get_dll returns a CLOB.

Maybe you are looking for