How to run an SP in a loop for?

Hello
I have following Ms.

PROCEDURE insert_and_update)
book_name IN table01.book_name%TYPE,
description1 IN table01.description1%TYPE
outside number status
);

I need to call this DS into the following loop.

because me in (select book_name, book_descfrom new_books) loop... end loop;

I did the following, but it didn't work. what Miss me?

declare
nn number (10): = 0;
Start
I'm in (select book_name, description of new_books) loop
exec insert_and_update (i.book_name, i.book_desc,: nn);
end loop;
end;

Please notify.

Thanks in advance
novideDBA

Remove 'exec ':

DECLARE
   nn   NUMBER (10) := 0;
BEGIN
   FOR i IN (SELECT book_name, description FROM new_books)
   LOOP
      insert_and_update (i.book_name, i.book_desc, :nn);
   END LOOP;
END;
/

: p

Tags: Database

Similar Questions

  • How to use the select statement in loop for

    Hi all

    My question is can I use a select statement in for loop like as follows.

    for the key in the selection of one_table key.

    When I use this am getting an error as found select invalid I ID

    How to select a statement use in loop for

    Please suggest me.

    Thank you
    Sree

    Hello

    You can use code below

    For key in (select button from table_a)
    loop
    If key.key = 1 then
    -insert statement
    on the other
    -Select statement
    end loop;

    Thank you
    Naveen.

  • HOW TO CREATE A STOP COMMAND IN LOOP FOR

    I have a problem. I can't put a stop to the VI attached here. I want to stop an iteration without support on cancel execution, because I want to connect this VI by a Subvi to control a motor continuous.

    Thank you

    Hello

    in order to stop your first vi, you can use a stop button for the while loop to 'or' with the release of your "equal" comparison function Then you can also use a local variable created the stop button to stop the loop for, configure it with a conditional expression (right click on the loop for > conditional expression).

    This way if you press "stop"button, you will stop the while loop and the loop together foor.

    Good bye

  • How to run a certain number of loops and stop

    Hello

    I now have a VI and I want to debug. Some time ago in a loop in my VI. I am interested in what happens after a few iterations.

     

    I want simple step by step, but not for the few lines at the beginning.

    How can I do this?

    Thanks in advance.

    Chuan

    Use a conditional probe out of the node iteration of the while loop.  You may need to run a wire from the node to the edge of the loop if you are not already using the node, then right-click the on wire and select Custom probe-> conditional I32 probe, and then select the conditions to get him to take a break.

  • How to export a value of a loop for?

    Hello

    I have a loop and a few other loops running at the same time. The loop is used to read the values of a PMT connected to a data acquisition. I need to export the value of the loop counter in order to to use in a case statement, which takes place outside of the loop. I tried the defintion it out of the loop, using automatic indexing (which exports an array containing all the values of the counter stacked from what I understand) or without automatic indexing, which as I understand it only exports the current value of the loop. But these two were not working, I tried for example to print the value of the counter on an indication on the map and it was like no matter what. On the contrary, when I put an indicator inside the loop it was printing the value of the counter normally. Do you have tips on how I could do or why is - it does not work? I also checked records the shift but it does not resemble their use is appropriate for my problem.

    Thank you

    George

    If you do a search (at least in LabVIEW 8.6.1) under "Help", "search for the help of LabVIEW" 'producer' you will find discussions on what you're trying to do. "Under the 'Fisland ', 'New" pulldowns, should also, under 'Frameworks' "Design Patterns" there are called examples ' Producer/consumer' will open a model in different ways to do what you are trying. As being the previous poster said, while that globals are not inherently bad, their use comes with certain risks. There has been a number of discussions on that (and the people who can provide one, so like, 'local' risk). Without going too deeply into it, the main concern is to know when the data is read from them are valid/updated compared to when it is written.

  • How to maintain the meter in a loop for

    Hello

    How to track meter in a loop? It's the way I've set up. ? Please suggest.

    Kind regards.

    Thankx,

    I don't know about this registry, its been a while that I started Labview.So this circuit is not optimized, but should work?

    concerning

  • How to export an image animation that loop for a certain period of time?

    I created a sequence of animation images with 6 photos chaque.12 seconds time and I put it for playback 25 times but when I export as a quicktime that it reads only once. How can I make the video loop exported 25 times?

    As far as I know, the only way to get in the gif / png is to repeat the executives making the size of the largest file 25 times, which is obviously not ideal.  But you might be able to control the number of loops in the application that you use to play the animation.  For example, I think you can do that from PowerPoint.

  • How to run the attached image control

    How to run vi in archive zip attached for image control.

    Communicate it always the entry is not valid.

    Thank you.

    For me, it works without worries. Furthermore, here the 3D image has been used.

    Indeed beautiful VI...

    Andrey.

  • How to run a while loop for 0.5 seconds?

    Hello

    I am doing a project and I'm stuck with the programming.

    Some time ago in a loop inside a box structure. When the real state of a structure box is enabled, the loop inside, should run for 0.5 seconds. How do this?

    Thanks in advance.

    Why you want to run a while loop? what you do inside that? If you want to perform any operation for a specific time, you can use a loop for.

  • How to get the items on a loop at the same time during the execution of the loop for

    Hello

    I am a student. I would like to know how to get the outside loop counter values For in parallel so that the loop runs rather than obtaining the value finally outside the loop for future prospects for the answers.

    Thank you

    Frederick

    You already said yes, and you have said some of the different ways (registrants, locals, reference, queue, etc.). Since the information was provided to your request, the thread can be considered closed? If you want details about how to implement something, you must provide the details on what you are doing.

  • Lean how to run the stop code when the highest level VI ends

    Hi people.

    I am a newbie of LV with 30 years of experience in embedded SW engineering.  I searched for how to run the stop code when a VI of highest level ends.  I found many examples, but they are horribly complicated.  A little birdie told me that such a model of simple design should not be so compilicated.

    My application is an application of high tension control to disable all HV checkpoints when the SW ends.  My VI code is running in a while loop with a stop button that leads out of the loop.  I can easily accomplish my requirement by programming with a sequence of plate that runs after the end of the main loop.  The technique of flat sequence does not work when the user clicks the Cancel button in the toolbar of façade, more than that market when the user clicks the close button of the application (X button) when you run the exe application.

    Can someone tell me please a simple technique, the code example that can show me a lean and elegant way to accomplish my task?  It doesn't have to be an obvious solution (for example a stop induced watchdog seems simple enough).

    Thank you - John Speth

    1. place this code in a VI:

    (also attached)

    Calling code in your VI of highest level like this:

  • How to stop a flat sequence (or timed sequence) which is inside a loop for

    The problem is this, I have a loop that repeats 10 times and inside this loop, I have a flat sequence (or timed sequence) with four images, each of this chassis to evaluate a different condition of a vector that I introduce.

    What I woud like for example is:

    I'm a fifth County of the loop for and in the case that part 2 does not meet the condition, the sequence of dish (or timed sequence) stops and starts the loop again but this time for the number of number 6.

    I would appreciate your response.

    You can't stop a sequence structure.  This is how they are made.

    What you should consider to get rid fo structures sequence and to change a state machine architecture.  There are many examples in LabVIEW, as well as on the Forums.  The big advantage of the state machine is that at the end of each State, it examines the conditions and determines which State then run. And that is exactly the description of the problem you are experiencing.

    Lynn

  • How to run the type of object...

    HI team,

    Please let me know how to run pl/SQL object type.

    create or replace TYPE  T_PARTY_ID_LIST  AS TABLE OF T_PARTY_ID; 
    create or replace TYPE  T_PARTY_ID AS OBJECT
     (SEQ NUMBER(10,0)
     ,COUNTRY_ID CHAR(2)
     ,ID VARCHAR2(50)
     ,ID_TYPE VARCHAR(3)
     ,DATE_FROM DATE
     ,DATE_TO DATE
     );
    
    create or replace PROCEDURE P_UPDATE_RICA_COUNT_ID
     (A_PARTY_IDS IN T_PARTY_ID_LIST
     ,A_ICAP_ID  IN number
     ) as
    v_id      sa_id_registration_counts.id%TYPE;
    
    --
    BEGIN
        FOR C IN (SELECT X.id_type, X.ID FROM TABLE (CAST(A_party_ids AS T_PARTY_ID_LIST)) X
                 WHERE X.ID_Type IN ('N','P','B')
                 ORDER BY X.ID_Type)
       LOOP
    --
          BEGIN
     --             
             UPDATE sa_id_registration_counts
             SET no_of_registrations = no_of_registrations-1
             WHERE id = V_ID
                   AND id_type = C.ID_Type;
    --
             IF SQL%ROWCOUNT < 1 THEN
                RAISE NO_DATA_FOUND;
             END IF;
    --
          EXCEPTION
             WHEN NO_DATA_FOUND THEN
                BEGIN
    --
                   INSERT
                   INTO sa_id_registration_counts
                      (id ,id_type,exclude_yn,no_of_registrations)
                   SELECT V_ID,C.ID_Type,'N',1 
                   FROM dual;
    --
                EXCEPTION
                   WHEN OTHERS THEN
                      RAISE_APPLICATION_ERROR(-20000,'Error updating RICA ID count ['||SQLERRM||']');
                END;  
          END;
    --
       END LOOP;  
    --
    END;
    --
    

    I'm trying, but receive an error message

    DECLARE
      A_PARTY_IDS SCOTT.T_PARTY_ID_LIST;
      A_ICAP_ID NUMBER :=12323;
    BEGIN
    
    A_PARTY_IDS.extend(1);
      SELECT T_PARTY_ID(1,'1','1','1',null,null) INTO A_PARTY_IDS(1)
       FROM DUAL;
       
      P_UPDATE_RICA_COUNT_ID(
        A_PARTY_IDS => A_PARTY_IDS,
        A_ICAP_ID => A_ICAP_ID );
    
    END;
    Error report -
    ORA-06531: Reference to uninitialized collection
    

    I do not know why you do what you do that is row-by-row (aka slow-by-slow), when you could do all this in a single merge - something like statement:

    create or replace PROCEDURE P_UPDATE_RICA_COUNT_ID
       (A_PARTY_IDS IN T_PARTY_ID_LIST,
        A_ICAP_ID  IN number)
    as
    begin
      merge into sa_id_registration_counts tgt
      using (select x.id_type, x.id, count(*) cnt
             from   table(cast(a_party_ids as t_party_id_list)) x
             where  x.id_type in ('N', 'P', 'B')
             group by x.id_type, x.id) src
         on (tgt.id_type = src.id_type
             and tgt.id = src.id)
      when matched then
        update set no_of_registrations = no_of_registrations - src.cnt
      when not matched then
        insert (tgt.id, tgt.id_type, tgt.exclude_yn, tgt.no_of_registrations)
        values (src.id, src.id_type, 'N', 1);
    end;
    /
    

    You v_id in your procedure, but you never defined anywhere, for as far as I could tell, so I made a few assumptions about the join condition. You will need to change if necessary.

    Meanwhile, for your procedure, you should do something like:

    DECLARE
      A_PARTY_IDS T_PARTY_ID_LIST := t_party_id_list();  -- initialised the collection here
      A_ICAP_ID NUMBER :=12323;
    BEGIN  
    
      A_PARTY_IDS.extend(1);
      A_PARTY_IDS(1) := T_PARTY_ID(1,'1','1','1',null,null); 
    
      P_UPDATE_RICA_COUNT_ID(
          A_PARTY_IDS => A_PARTY_IDS,
          A_ICAP_ID => A_ICAP_ID );
    end;
    /
    

    Another thing - you seem to like selection of the many double - if you're in PL/SQL, then you can just assign variables directly (overall; there are a few exceptions, depending on your version of the database).

  • How to run execute immediate with variables

    Hi friends,
    How to run execute immediate with variables in v_stmt below?
    I don't know how to declare value I have here.
    Set serveroutput on;
    DECLARE
       i        VARCHAR (20);
       v_stmt   VARCHAR2 (100);
    
       CURSOR c
       IS
          SELECT sqlid FROM temp1;
    
    
    BEGIN
       OPEN c;
    
       LOOP
          FETCH c INTO i;
          EXIT WHEN c%NOTFOUND;
          DBMS_OUTPUT.put_line (i);
          v_stmt := 'select * from table(dbms_xplan.display_cursor('&i',null))'
          execute immediate v_stmt;
       END LOOP;
    
       CLOSE c;
    END;
    /
    Regds,
    Kunwar.

    You must first use a variable binding (named ': v' in the SQL statement in my example):

    set serveroutput on;
    DECLARE
       i        VARCHAR (20);
       v_stmt   VARCHAR2 (100);
    
       CURSOR c
       IS
           -- modified for a quick test
          SELECT sql_id FROM v$sql where child_number > 2;
    
    BEGIN
       OPEN c;
    
       LOOP
          FETCH c INTO i;
          EXIT WHEN c%NOTFOUND;
          DBMS_OUTPUT.put_line (i);
          v_stmt := 'select * from table(dbms_xplan.display_cursor(:v,null))';
          execute immediate v_stmt using i;
       END LOOP;
    
       CLOSE c;
    END;
    /
    

    However because your SELECT statement returns multiple lines, you need to adapt your code to process all rows returned (as already suggested in first response to your message).

    Instead of using the PL/SQL, I recommend you to generate a SQL file using only SQL, and then run the generated SQL file.
    For example:

    spool edx.sql
    set serveroutput on
    declare
    v_stmt varchar2(100);
    v_q char(1):='''';
    begin
    dbms_output.put_line('spool edx.log');
    for s in (select sql_id from v$sql where child_number >2)
     loop
      dbms_output.put_line('select * from table(dbms_xplan.display_cursor(' || v_q || s.sql_id || v_q || ',null));');
     end loop;
     dbms_output.put_line('exit');
    end;
    /
    spool of
    

    This generates a file similar to:

    spool edx.log
    select * from table(dbms_xplan.display_cursor('5rygsj4dbw6jt',null));
    select * from table(dbms_xplan.display_cursor('5rygsj4dbw6jt',null));
    select * from table(dbms_xplan.display_cursor('5rygsj4dbw6jt',null));
    select * from table(dbms_xplan.display_cursor('fsbqktj5vw6n9',null));
    select * from table(dbms_xplan.display_cursor('6q42j0018w7t8',null));
    select * from table(dbms_xplan.display_cursor('a5mmhrrnpwjsc',null));
    select * from table(dbms_xplan.display_cursor('3c1kubcdjnppq',null));
    select * from table(dbms_xplan.display_cursor('3c1kubcdjnppq',null));
    select * from table(dbms_xplan.display_cursor('9gkq7rruycsjp',null));
    select * from table(dbms_xplan.display_cursor('f0wj261bm8snd',null));
    select * from table(dbms_xplan.display_cursor('ab3swhv5g138y',null));
    select * from table(dbms_xplan.display_cursor('6vgvyh4xw9c5g',null));
    select * from table(dbms_xplan.display_cursor('ak5crjygnpk60',null));
    select * from table(dbms_xplan.display_cursor('9p6bq1v54k13j',null));
    select * from table(dbms_xplan.display_cursor('19x1189chq3xd',null));
    select * from table(dbms_xplan.display_cursor('7sx5p1ug5ag12',null));
    select * from table(dbms_xplan.display_cursor('730vdzhng6m6g',null));
    select * from table(dbms_xplan.display_cursor('730vdzhng6m6g',null));
    select * from table(dbms_xplan.display_cursor('0v3dvmc22qnam',null));
    select * from table(dbms_xplan.display_cursor('0v3dvmc22qnam',null));
    select * from table(dbms_xplan.display_cursor('a1zv6wju3ftgv',null));
    select * from table(dbms_xplan.display_cursor('7ng34ruy5awxq',null));
    select * from table(dbms_xplan.display_cursor('7ng34ruy5awxq',null));
    select * from table(dbms_xplan.display_cursor('b2gnxm5z6r51n',null));
    select * from table(dbms_xplan.display_cursor('b2gnxm5z6r51n',null));
    select * from table(dbms_xplan.display_cursor('g4gp07gt2z920',null));
    select * from table(dbms_xplan.display_cursor('1gu8t96d0bdmu',null));
    select * from table(dbms_xplan.display_cursor('g00cj285jmgsw',null));
    select * from table(dbms_xplan.display_cursor('g00cj285jmgsw',null));
    select * from table(dbms_xplan.display_cursor('g00cj285jmgsw',null));
    select * from table(dbms_xplan.display_cursor('bn4b3vjw2mj3u',null));
    select * from table(dbms_xplan.display_cursor('38243c4tqrkxm',null));
    select * from table(dbms_xplan.display_cursor('2abjfnvy5rkyg',null));
    select * from table(dbms_xplan.display_cursor('350f5yrnnmshs',null));
    select * from table(dbms_xplan.display_cursor('350f5yrnnmshs',null));
    select * from table(dbms_xplan.display_cursor('3s1yukp05bzg6',null));
    select * from table(dbms_xplan.display_cursor('3s1yukp05bzg6',null));
    select * from table(dbms_xplan.display_cursor('1tgukkrqj3zhw',null));
    exit
    
    PL/SQL procedure successfully completed.
    

    Edited by: P. Forstmann March 20, 2013 19:06

    Edited by: P. Forstmann March 20, 2013 19:33

  • How to run a script in environment unix and how to run this program into a toad

    Hello guys
    Please help me!
    How to run a script in the unix environment (Group of programs (cursor, programs...) stored in a file file.sql).

    file.sql luks like this


    WHENEVER OSERROR EXIT FAILURE
    WHENEVER SQLERROR EXIT SQL. SQLCODE
    SET the position
    SET serveroutput size 1000000
    coil ins2aais_jobs;
    SELECT "FILE IS: ins2aais_jobs' FROM dual;"
    SELECT "STARTED:' began, to_char (sysdate," YY/MM/DD HH24:MI:SS) TIME FROM dual; "
    DECLARE
    lv_upd_ct number: = 0;
    lv_ins_ct number: = 0;
    lv_exp_ct number: = 0;
    ---------------------

    date of lv_FROM_date;
    date of lv_to_date;
    lv_mon_or_week varchar2 (20);
    date of lv_week_end_date;
    lv_month_indicator varchar2 (8);
    -------------------------------------------------
    Aais CURSOR IS
    SELECT the ID substr (ID, 1, 7), SSN, FNAME, LNAME
    , SUCCESS, COMPENSATE, INSTALLATION
    , MODU, DRIVE, REVERSE, SUCC_RATE
    TRANS_TOTAL, FILE_NAME, WEEK_END_DATE
    RUN_DATE
    OF weekly_aais;

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

    I aais % rowtype;


    -------------------------
    PROCEDURE p_ins (r1 aais % ROWTYPE) IS
    BEGIN
    BEGIN
    INSERT INTO AAIS_JOBS
    (ID, SSN, SUCCESS, COMPENSATE, INSTALL, MODU
    , DRIVE, REVERSE, SUCC_RATE, TRANS_TOTAL
    FILE_NAME, WEEK_END_DATE, RUN_DATE
    AAIS_FNAME, AAIS_LNAME
    )
    VALUES
    (r1.ID, r1. SSN, r1. SUCCESS, r1. COMPENSATE, r1. INSTALLATION, r1. MODU
    r1. DISK, r1. CONVERSELY, r1. SUCC_RATE, r1. TRANS_TOTAL
    r1. File_name, r1. WEEK_END_DATE, r1. RUN_DATE
    r1. FNAME, r1. LNAME
    );
    lv_ins_ct: = lv_ins_ct + 1;
    EXCEPTION
    WHILE OTHERS then
    DBMS_OUTPUT. PUT_LINE ('ERROR IN THE INSERT STATEMENT');
    DBMS_OUTPUT. Put_line (SQLERRM);
    lv_exp_ct: = lv_exp_ct + 1;
    END;

    END;

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

    PROCEDURE p_disp_msg IS
    BEGIN
    DBMS_OUTPUT. Put_line (' number of insertion: ' | to_char (lv_ins_ct));
    DBMS_OUTPUT. Put_line (' number of Exceptions: ' | to_char (lv_exp_ct));

    lv_ins_ct: = 0;
    lv_exp_ct: = 0;
    END;

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

    BEGIN

    lv_FROM_date: = to_date ('& 1', 'DD-MON-RR');
    lv_to_date: = to_date ('& 2', 'DD-MON-RR');
    lv_mon_or_week: = 'and 3';

    lv_month_indicator: = di.get_month_ind (lv_mon_or_week, lv_FROM_date, lv_to_date);

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

    REMOVE FROM AAIS_JOBS
    WHERE WEEK_END_DATE = lv_to_date;

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

    COMMIT;

    Aais OPEN;
    LOOP
    EXTRACT the aais IN i;
    OUTPUT WHEN aais % NOTFOUND;
    BEGIN
    p_ins (i);
    END;
    END LOOP;
    Aais CLOSE;

    commit;

    DBMS_OUTPUT. PUT_LINE ('INSERT INTO TABLE JOBS AAIS');
    p_disp_msg;


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

    END;
    /
    SELECT "FINISHED: ' | '. TO_CHAR (sysdate, "MM/DD/YY HH24:MI:SS'") FROM dual
    /
    spool off
    "exit";


    and also how we organize this into a toad?


    Thank you.

    Hello

    You vous connecter connect to oracle through unix and SQL prompt, run these commands in a .sql file.

    Toad, you can run the instructions individually by selecting the sql statements or in a set with the F5 key.

    Kind regards
    AJR

Maybe you are looking for