trouble with inner for loop in my procedure values

Hello...
I use oracle 10g and this is my procedure...


create or replace procedure sales_information is

v_qty number (10);
Number of rem_qty (10): = 0;

cursor pck_quantity is
Select * from sales_info;

cursor no_of_labels is
Select ceil (sum (nvl (total_quantity, actual_quantity)) / 400) in the sales_info;

Start

no_of_labels j
loop
because me in pck_quantity
loop

Select nvl (i.total_quantity, i.actual_quantity) in the v_qty of sales_info;
If v_qty > = i.packed_quantity and rem_qty = 0 then

Insert values sales_order-
REM-quantity: = v_qty - i.packed_quantity;
v_qty: = rem_qty;
"exit";


otherwise if v_qty > = i.packed_quantity and rem_qty > = 400 then
Insert values sales_order-
rem_qty: = v_qty-rem_qty;
v_qty: = rem_qty;
"exit";

otherwise if v_qty > = i.packed_quantity and rem_qty > 0 then
rem_qty: = v_qty + rem_qty - i.packed_quantity;
v_qty: = rem_qty;
Insert values sales_order-


Otherwise, if v_qty is null and rem_qty > 0 then

Insert values sales_order-

otherwise if v_qty < i.packed_quantity and rem_qty: = 0 then

rem_qty: = v_qty;

otherwise if v_qty < i.packed_quantity and rem_qty > 0 then

If (v_qty + rem_qty) > 400 then
Insert values sales_order-
rem_qty: = v_qty + rem_qty - i.packed_quantity;
v_qty: = rem_qty;

end if;
end if;
end loop;


end loop;


Inside of the loop will retrieve values of v_qty for each iteration of the loop outside when he runs the only select the following:

Select nvl (i.total_quantity, i.actual_quantity) in the v_qty of sales_info;

and therefore loses the previously calculated values of v_qty and rem_qty
in the previous iteration of the loop outside whereas I want inside the loop iterate on it previously calculated the values of v_qty and rem_qty but can not think of a work around.

Tags: Database

Similar Questions

  • For loop tunnel exit "Last value" output of default values

    Salvation OR community,

    Today, I came across a probem of LabVIEW stange. A tunnel of release of "Last value" to a for loop back the default values instead of the last real value. The code is below:

    Below as screenshots of probes 44 and 45.

    When the probe 44 contains al the data (all the planks are present (and the correct "Testrack Module" is used)) probe 45 is empty.

    I already tried to remove the complete thread and it rewire. The result was the same.

    However, I also tried to use registers with shift instead of the tunnels and the code works now (see below for the code).

    The used version of Labview is 2013 SP1.

    I hope you can help,

    Tim

    Edit: If the images are too small, you can drag it to a new tab, and they become the original size.

    Tim,

    My first assumption: the because the loop never executes as you pass an empty array to an entry of automatic indexation.

    Another option, which is difficult to see in the screenshot: are there two entries of tunnels over the probe nr 42?

    Norbert

  • slider with a for loop

    Hi all

    I have a simple slider in my pl/sql procedure. I use the method for the slider of the loop and retrieve the values below.


    DECLARE

    VAR_A VARCHAR2 (100);

    CURSOR C1 IS
    SELECT DEPT_NAME, DEPT_NO OF THE DEPARTMENT;
    BEGIN

    FOR I IN C1
    LOOP
    VAR_A: = I.DEPT_NAME;
    END LOOP;

    -etc etc.
    -etc etc.

    EXCEPTION
    WHILE OTHERS THEN
    DBMS_OUTPUT. Put_line ('hello');

    END

    This workfine but if the DEPT table does not all records in it, it goes directly to the management of exceptions, and if there are all the other instructions after the FOR LOOP, they will not be executed. I know there is a method to use the cursor (instruction FETCH) more, but I want to know what is wrong by using the FOR LOOP.

    The strange thing about this example is, even if I catch the exception, the program stops and if the DEPT table has no recording errors.

    Any suggestions or tips are greatly appreciated.

    the program stops and if the DEPT table has no recording errors.

    This seems a little suspicious. Probably another error product which is now hidden simply because of your manager WHEN of OTHER of exceptions, that didn't come out the real error message.

    I recommend getting rid of the exception handler together and after the release of the thrown exception.

  • Capture of sequences of images - issues with nested for loops

    Hi all

    I've written a vi. to capture a number of images ("Image") and save these images, sent to a folder of my choice.  Each image is identified sequentially.  However, I would like to make a number of iterations ("run") of this capture sequence, such that each image file name would be "Filename (Run) _(Image_No).png", for example run 5, image 10 'Filename 5_10.png.  I tried a nested for loop for this but I have an error message 'Current asynchronous i/o Operation' (I have attached a printscreen).

    Can someone help me solve this problem?  Please find attached my vi.

    Sincere greetings and thanks,

    Miika

    Hi toto26,.

    Thank you for your response.  I solved the problem by using a sequence structure flat - file in the first image and all the treatment in the second.

    Kind regards

    Miika

  • Operation on line on table with a For loop

    Hello

    I work with a wide range of dimensions column one. I'm doing the following

    for i = 1:size (A) / 2

    B (i, :) = A (1 + (i-1) * 2:i * 2))

    So, for example if

    A =.

    0

    1

    2
    3
    4
    5
    6
    7

    then

    B =

    0 1

    2 3
    4 5
    6 7

    My approach was to use a subset of the table inside the loop for to select several items, but I don't know how to transpose the selected items in a new line to create the table (B) is there a simpler approach?

    Thank you

    Mike

    try experimenting with the table to reshape feeding your table entry and re-sizing for a 2d aray of output. It is much faster to use a loop For, because the data is never moved and LV just changes the dimensions of the matrix and updates the stride.

    Ben

  • for loop in a procedure stored

    I have Windows XP with 10g 10.2.0.1.0
    I got errors that I executed the following codes. Can I use select in exception inside the loop, if not, I have another other way to solve the problem? Help, please.

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    249/3 PLS-00103: encountered the symbol "EXCEPTION" when expected
    of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while < ID >
    < between double quote delimited identifiers of > < a variable binding > < <
    Close current delete fetch locking insert open rollback
    SAVEPOINT SQLExecute set pipe fusion commit forall

    247/17 PLS-00403: expression "V_COUNT" cannot be used as a target-INTO
    a SELECT/FETCH statement



    v_count NUMBER (1): = 0;
    for v_count in 1.cols.count)
    loop
    SELECT 1 IN v_count FROM USER_TAB_COLUMNS WHERE table_name = nom_table_p
    AND column_name = cols (v_count);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    raise_application_error (-20001, passes (v_count) |) 'does not exist');
    while others then
    raise_application_error (-20011, sqlerrm);
    end loop;

    Hello

    Of course, you can have an EXPECTION article inside a loop. Ensure that correspondents starements BEGIN and END are inside the loop, too, like this:

    ...     v_count NUMBER(1) := 0;
    BEGIN
         FOR  v_count IN 1..cols.count()
         LOOP
              BEGIN
                   SELECT  1
                   INTO      v_count
                   FROM      USER_TAB_COLUMNS
                   WHERE      table_name      = p_table_name
                   AND     column_name       = cols (v_count);
    
                   ...
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                           RAISE_APPLICATION_ERROR ( -20001
                                       , cols (v_count) || ' does not exist'
                                       );
                   WHEN OTHERS THEN
                           RAISE_APPLICATION_ERROR ( -20011
                                       , SQLERRM
                                       );
              END;
         end loop;
    END;
    

    This is one of the many situations in which withdrawal correctly your code can avoid mistakes.
    Notice how it is easy, given the statements BEGIN, EXCEPTION, END or LOOP, to see where the corresponding END, EXCEPTION, BEGIN or LOOP statement is and what the scope of this block.

    Do you really need (or even want) to trigger the error-20011? Why not raise the original instead error? Why do something with these errors: why not let the default Oracle error handling to catch them?

    On the other hand, tyou have two separate variables, called v_count.
    That reported on the first line above (before the BEGIN statement) is not used anywhere.
    It is set in the HEART... Declaration of the LOOP and is used inside this loop, including the EXCEPTION section withion that loop.

    Do you really need to do a select... INTO in the loop? If possible, it would be less evil and more effective, for the results of the SELECTION... AT the same time, you get the other data.

    Published by: Frank Kulash, August 10, 2010 13:35
    Deleting duplicate EXCEPTION statement.

  • Activation of channels with a for loop

    So basically, I try to select each one of my channels in the order and a complete set of tasks on each.  I want to be able to specify which channels are ACTED, so I already have a picture of my selected channels, but when I try to run the loop, it is said that "activeChannels =" needs a picture.

    I know that my table of channelNumber is good, but I can't figure out how to make this loop to work.

    Here's my loop for:

    for (var i = 0; i < channelNumber.length; i ++) {}

    doc.activeChannels = channelNumber [i];

    do stuff

    }

    I actually just thought of it.  When I declared my channelNumber variable I just declare "channelNumber = new Array (doc.activeChannels)" instead of "= doc.activeChannels channelNumber" and it worked fine.  Seems silly not to accept a single channel.

  • G6-1c74ca: re installed windows now in trouble with drivers for pci devices and network control

    Hi I cannot locate the drivers I need to download for my laptop. I have recently reinstalled windows and it can not find the dirvers for my network control devices and pci. The model number is g6-1c74ca and the product number is A3J86UA #ABC.

    Yes on the page that I linked above you need Realtek LAN and LAN Realtek wireless network and also Intel Management Engine Interface under Chipset.

    If it's "the Answer" Please click "Acceot as Solution" to help others find it.

  • Problems with nested for loops - save images from a camera


    Dear Norbert_B,

    Thank you for your response.  I solved the problem by using a sequence structure flat - file in the first image and all the treatment in the second! Easy as pi!

    Kind regards

    Miika

  • For loop Query - by assigning values to Variables

    I have the following code slot in my flash file...

    Q2A random + (10) = 1;
    Q2B random + (10) = 1;
    years2 = q2a + q2b;

    I have 18 thing similar to this in my file, where it basically... increments q3a etc. Y at - it a simple way of creating a loop that will iterate through all of them? I could not the syntax just when I tried it myself.

    :

  • CURSOR for loops or an associative array

    I just want to know the advantages and disadvantages of the CURSOR for loops. As a general rule, what guys do you prefer: associative array with CURSOR for loops?


    If you use the CURSOR for loop, is it not difficult to debug?

    PL/SQL Developer, I do not see what values are stored in the CURSOR for loop (in SP master_proc below) as
    There are no variables to watch. Not sure if the TOAD can show these values

    If I had used an associative array (master_proc2 below), I can see the values stored in the table by clicking on "show Collection"variable in PL/SQL developer.




    create table emp2 as select * from emp;
    
    
    create or replace procedure my_proc(p_empno in number)
    as
    begin
    update emp2 set sal=sal+100 where empno=p_empno;
    end;
    /
    
    --Using CURSOR FOR loop
    
    create or replace procedure master_proc
    as
    begin
         for rec in (select empno from emp2 where empno>7700)
         loop
              my_proc (rec.empno);
         end loop;
    end;
    /
    
    -- Using Associative arrays
    create or replace procedure master_proc2
    as
    type v_empno_type is table of number index by pls_integer;
    v_empno v_empno_type;
    
    begin
    select empno bulk collect into v_empno from emp2 where empno>7700;
    
    for i in 1..v_empno.count
     loop
        my_proc (v_empno(i));
     end loop;
    end;
    /

    VitaminD wrote:
    Thank you Tubby. If you are faced with a situation where you MUST use a loop. Then you would go to associative arrays rather than CURSOR FOR loops. Right?

    Doesn't happen too often, but if/when then I would do as I said in my first post. Use the transformation, the collection table in BULK and FORALLs.

    If we use your example posted, I would NOT spend a single table (in a loop mode) value I would be transmitted in the OVERALL picture and treat it with FORALL.

    So, I would still use neither of the approaches that you mentioned.

  • Parallel for loop 2D table

    Hello

    I don't have any experience with parallel for loops, so I need your help.

    Goal: To do a calculation (average, average) on the rows (or columns) table 2D as quickly as possible. The calculations are independent of each other and I would get a table 1 d with the results.

    I read a few posts on parallel for loops and I would like to find an example for my trivial problem, but I can't.

    Could you help me, it is possible is improve it the effectiveness of the calculation on lines with parallelism in LabVIEW? and it is, could you post an example how to do?

    Thank you

    If the speed issues, do not write your own "average." First of all, it already is in the range of statistics, but then you must be inline your average VI or do the calculation explicitly (as shown below). the size of the array never changes for the duration of the loop, it seems redundant to get the size of the array on each iteration.

    Here's what you could do.

    On my bench, it's much faster than the use of 'mean.vi' of the palette. Average a overhead, Subvi (1) (2) needs to get N with each call and (3) is also an unnecessary error checking.

    (Sorry, I have 32 processors, so the number of instances is set a little high. Modify if needed).

  • How to call a script with an officer designated in a loop of a procedure asynchronously and then wait for the children at the end.

    I tried to call a script in a loop of a procedure of Jython, using startcmd.bat and sub-process; the command succeeds when I omit the "-AGENT_CODE = MySA_Agent1 ' parameter (highlighted and emboldened)

    But omitting the '-AGENT_CODE = MySA_Agent1 "the scenario starts with the default value (no Agent) and subsequently fails to find the w: drive. Wen, I understand the '-AGENT_CODE = MySA_Agent1 ' the command fails with return code 2.

    Also, it seems that the OdiWaitForChildSession will not work with this approach, because the sessions so are not recognized as child sessions at all.

    Another simpler process is to have a step for each folder that I want to ask and just use OdiTools and StartScen; but it's a huge process because it could have potentially many interrogation records.

    Please Guide:

    from __future__ import with_statement

    from com.ziclix.python.sql import zxJDBC

    import of subprocesses

    #GetSources.py

    def getdata (c, stmt):

    Try:

    c.Execute (stmt)

    except zxJDBC.Error, e:

    raise Exception (e, stmt)

    Another thing:

    return c.fetchall)

    driver, url, user, passwd = ("< % = odiRef.getInfo ("SRC_JAVA_DRIVER") % > ',")

    '< % = odiRef.getInfo ("SRC_JAVA_URL") % >',

    '< % = odiRef.getInfo ("SRC_USER_NAME") % >',

    '< % = odiRef.getInfo ("SRC_PASS") % >'

    )

    Try:

    subprocess.check_call ([' cmd',

    '/c',

    "dir" command

    « t: »

    ])

    except subprocess. CalledProcessError, e:

    raise the Exception (e, ' Mapping The for the t: drive has not completed in the previous step. aborting... ")

    Another thing:

    folddic = {}

    with zxJDBC.connect (url, user, passwd, pilot) as conn:

    with conn.cursor () heart:

    stmt = "SELECT SOURCE_SYSTEM, ABS (DIC - ROWNUM) FROM (SELECT SOURCE_SYSTEM, COUNT (1) DIC FROM DIR_USER.). (RÉPERTOIRES WHERE ACTIF = \ 'Y\' GROUP BY SOURCE_SYSTEM) ".

    for the NTC in getdata (cur, stmt):

    folddic [Str(CNT[1]) [:-2]] = cnt [0]

    because me in folddic.iterkeys ():

    Try:

    subprocess.check_call ([' cmd',

    '/c',

    "startcmd.bat,"

    "OdiStartScen,"

    '- SCEN_NAME IS POLL_T_DRIVE_AND_SUBDIRS',

    '-SCEN_VERSION = - 1',

    '-SESSION_NAME = Polling_' + str (folddic.get (i)).

    '-AGENT_CODE = MySA_Agent1',

    '- SYNC_MODE = 2',

    '-Interfaces.VarSubDirectory =' + str (folddic.get (i)).

    '- Interfaces.VarPollInterval = 5'.

    '- Interfaces.VarTimeout = 4'.

    '- Interfaces.VarWait_N_Minutes = 30000 ".

    ])

    except Exception, e:

    raise the Exception (e)

    Another thing:

    Print "Called".

    Hello

    After much deliberation with the approach Prrocedure to do that are installed with the package, has been described in https://blogs.oracle.com/dataintegration/entry/using_variables_in_odi_creatin.

    It takes away that the question of the child scenario waiting problem sessions will be managed ODI.

    It was a good learning experience anyway.

    Thank you for contributing A J Chantal Mangano

    and JeromeFr for your taste.

  • Hello, I recently bought a new iMac and I am wanting to install Lightroom for her, but I'm having some trouble with the key to series is not recognized. There is no disk drive on the new Mac, so I can't just pop the disc in. Is there anyway I

    Hello, I recently bought a new iMac and I am wanting to install Lightroom for her, but I'm having some trouble with the key to series is not recognized. There is no disk drive on the new iMac, so I can't blow my disc. Is there a way I can download it simply by using the key to series on my package? I tried the section "Redeem Code", but said air key is not valid. Thank you

    Download & install instructions https://forums.adobe.com/thread/2003339 can help

    -includes a way to go to a page to download the Adobe programs if you do not have a disk or drive

    -Cloud desktop http://helpx.adobe.com/creative-cloud/help/creative-cloud-desktop.html

    -Cloud Getting Started https://helpx.adobe.com/creative-cloud.html

    -you will need to enter your original serial number during the installation for non-Cloud programs

    - or kglad links in response to #1 here can help https://forums.adobe.com/thread/2081216

    Also go to https://forums.adobe.com/community/creative_cloud/creative_cloud_faq

  • How I continuously loop frames with pause for 20 seconds in each image of the scene even without going to the next scene?

    How I continuously loop frames with pause for 20 seconds in each image of the scene even without going to the next scene? There are buttons for other scenes in these images. The below works well until I got to the last frame of the scene, then he goes to the next scene and plays. How can I make one loop continuously.

    Stop();

    var: timer = new Timer (20000,0); / / <--

    timer.addEventListener (TimerEvent.TIMER, timerHandler);

    Timer.Start ();

    function timerHandler(event:TimerEvent):void {}

    this.nextFrame ();

    or if you want to jump for example 5 executives

    this.gotoAndStop(this.currentFrame+5);

    }

    Thanks for any help.

    If you want to stop your timer, use the stop() method:

    Timer.Stop ();

    PS when you use the adobe forums, please check the useful/correct, if there is.

Maybe you are looking for

  • hppsc2210

    My HP psc 2210 won't ring when sending a fax. There is the fax tone, but there is no sound. It seems to meet the incoming faxes, but will not send outgoing faxes A few weeks ago there were thunderstorms, which invalidates one phone on one line differ

  • HP 15-D103TX computer laptop problem: Windows does not detect the dedicated graphics card

    Hi all I recently bought a laptop HP 15 - D103TX , which is held responsible for Free on BACK. I have updated my Windows 8 operating system and have installed all the drivers from the HP website. The laptop has dedicated 2 GB Nvidia Geforce 820 M gra

  • Lost all control computer after going online

    Original title: contract of end-user for the microsoft drivers I need help I broke this agreement because I wasn't aware of this my computer was made by dell, I went there web site and used my service number to get all the updates for my computer, I

  • 802.1 x (dot1x) with IP phone / workstation using several authentication domains (MDA)

    Scenario: Workstation (behind the phone) 8.5 (2) software IP Phone 7911 ACS 4.1 with AD on the same server Cisco switch WS-C3750E-24PD with c3750e-universalk9 - mz.122 - 53.SE1.bin Guide used: http://www.Cisco.com/en/us/Tech/tk389/tk814/technologies_

  • Test command of the AAA for EAP - TLS authentication for wireless users

    Hi all Can anyone suggest me the test command to verify the eap - tls authentication for the Cisco WAP's wireless. If it's an authetication jump we can use the command to test the connection below Radius of group aaa Testwap-01 #test [email protected