Need help with a loop of a function

Hello experts,
I'm in a bit of a mess of ideas,

I have a form with different fields of research.

based on the values that I'm passing, I'm back certain values in my form
Here's my function
CREATE OR REPLACE function LOTTO_EROUTES.f_forecast(p_ret_num        in varchar2, 
                                                    p_item_id        in number,
                                                    p_curr_date      in date,
                                                    p_expected_stock out number ,
                                                    p_actual_stock   out number,
                                                    p_inst_settled   out number,
                                                    p_prev_date      out date  ,
                                                    p_range          out number,
                                                    l_settled_avg    out number,
                                                    p_coefficient    out number                                                  
                                                    )
return number is
l_forecast_num number;
l_curr_cdc  varchar2(6);
l_prev_cdc varchar2(6);
l_forecast_err varchar2(50) := 0;
l_game_id number;
begin

  select game_id,STOCK_COEFF_LEVEL_DAYS,IPS_SETTLED_RANGE_DAYS
  into l_game_id,p_coefficient,p_range
  from items
  where item_id =p_item_id;


l_curr_cdc  := ltrim(rtrim(to_char(f_get_cdc_num(p_curr_date),999999)));

l_prev_cdc := (l_curr_cdc - p_range);

p_prev_date := f_get_cdc_date(l_prev_cdc);

select count(serial_number) 
into p_inst_settled
from LOTTO_INSTANT_TRACK
where game_id = l_game_id
and retailer_num = p_ret_num
and status = 'Settled'
and cdc between l_prev_cdc and l_curr_cdc ;

l_settled_avg := ceil(p_inst_settled / p_range);

p_expected_stock := ceil(l_settled_avg * p_coefficient);

select count(serial_number) 
into p_actual_stock
from LOTTO_INSTANT_track
where game_id = l_game_id
and retailer_num = p_ret_num
and status like 'Confirmed';

l_forecast_num := ceil((p_expected_stock - p_actual_stock));

return l_forecast_num;

exception
when others then
dbms_output.put_line(sqlerrm);
return l_forecast_err;
end;
/
Now I'm passing 1 single value for p_ret_num (retailer number) in my service, I appreciate to p_item_id and p-curr_date, which is by default sysdate.

now, I should be able to convey all the dealer number and return these values accordingly.

I think I have a LOV which will have the option 'ALL' through which the user will select and it should return all of its values.

I know I should have a loop but don't know how to do this. Anyone can guide me please.

Thank you

Turning the LOV 0 value for * ALL * as you said in the previous thread here...
Help in LOV

The code calling the function will then look like this...

declare
     CURSOR Fetch_Ret IS
          select retailer_num
          from lotto_retailers
          where agent_status_id = 2
          AND retailer_num = DECODE(:criteria.retailer_num,0,retailer_num,:criteria.retailer_num);

     default_date date := :oe_header.order_date;
begin
     :oe_lines.order_date_disp := default_date;

     FOR Get_Ret IN Fetch_Ret LOOP
          :OE_LINES.FORECAST_CNT := f_forecast(  Get_Ret.retailer_num,
                              :criteria.item_id,
                              :OE_LINES.order_date_disp,
                              :OE_LINES.expected_stock,
                              :OE_LINES.current_retailer_stock,
                              :OE_LINES.avg_calculated_amt,
                              :OE_LINES.from_date,
                              :OE_LINES.calc_stock_coefficient,
                              :OE_LINES.avg_daily_sales,
                              :OE_LINES.stock_coefficient_used
                                   );

          :OE_LINES.AVG_WEEKLY_SALES := (     :OE_LINES.avg_daily_sales * 7 );
     END LOOP;
END;

If the data block is tabular, then use GO_BLOCK outside the loop and the NEXT_RECORD integrated inside the loop.

-Clément

Tags: Oracle Development

Similar Questions

  • Need help with while loop and shift registers

    I have a broad set of data and required to read data at maybe 200 samples at a time to process these samples through my VI and have add and concatenate a file separate lvm.  The part where I am confused is the shift registers. How can I limit the number of samples read in an iteration? How do the while loop to stop when all data are read in?

    I have attached my diagram, there may be something wrong with my technique?

    This will give you an idea.  There are a lot of other (probably more effective) methods.  It is a basic solution, quick and dirty to help you grasp the overall concept.

  • Need help with network home using Airport extreme

    I need help with my home network.  I'm not very aware when it comes to all things network.  Here's how my network is currently set up.

    Cable modem to Airport Extreme for Gigabit Switch.  Cables come out of the switch to all areas of the House.  I have 2 other extreme airport connected in other rooms of the House directly on the wall that dates back to the switch.  I hope I am explaining that properly.

    My problem is that this seems to have caused some of my connections cable does not work.  When everything is configured, it has worked well.  All connections in the House worked.  Then we have disconnected one of the extreme airport and moved to another location in the House to have the best wifi coverage.  Since that time, a lot of the ethernet wall plugs are not working.  For example, when I plug in my Macbook Pro in making ethernet in my kitchen, it says connected but it has an assigned ip address and cannot connect to the internet.

    Any help you can provide would be great.

    I would like to get the return tech to help you to...

    But it is likely that something (or someone) has tampered with the settings.

    The layout is fine... but you can cause problems with the network by creating a loop.

    This can happen because the AE you moved is connected wrongly... somewhere in the network it is connected to the switch again.

    Or AE is set to expand wireless... It's FAKE... It will loop the network on the back main EI wireless.

    Unplug the two AE you have that function as extensions...

    Turning off everything else... then it works again...

    Do it in this order.

    Modem... Wait 2 min

    AE... Wait 2 min

    Switch.

    Now check that the network is working properly... power of customers in various locations and make sure everything is good.

    If so, then manually reset the two AE of factory and redo their installation.

  • Need help with drag and drop

    IM really new to this program as a

    day new hehe and I need help. im making a game quiz and your supposed

    ED to score in the hoop with a circle.  I have the

    codes for the drag and drop for the circle, but I need help with the collision between the Hoop and the ball, I want to go to the image next or gotoandPlay when the ball touches the ring. HELP PLEASE

    You should not attach code to objects.  and you can be able to happen by using a loop.

    Start by removing all the code the suggested by maqro (i.e. as3) and by removing all the code attached to objects.

    use:

    {yourobject.onPress = function ()}

    this.startDrag ();

    }

    {yourobject.onRelease = yourobject.onReleaseOutside = function ()}

    this.stopDrag ();

    {if (this.) HitTest (whatever))}

    do something

    }

    }

  • I'm suddenly needing help with my browser Firefox (6.0.2)

    Hello
    I'm suddenly needing help with my browser Firefox (6.0.2)

    (OS: I use Windows XP).

    When I open the browser, I don't see is a totally white screen of white, with all the toolbars at the top.

    I know that my physical connections are very good: I have tested the modem, turned the pc market etc and I can also receive/send emails.

    This problem started today, September 8, 2011 and has never happened before.

    Is it a coincidence that Firefox itself to day before I disconnected yesterday evening? Could this be something to do with this particular new update?

    I also noticed that just before I "opened" Firefox, I now get a small box indicating:

    [JAVASCRIPT APPLICATION]
    Handl exc in Ev: TypeError: this oRoot.enable is not a function

    This never appeared before - I hope that it offers a clue has what is wrong.

    The browser not be stuck in Mode safe, said by the way.

    Of course, I can't find solutions to the problem on the internet, I don't physically see all Web sites!
    (A friend sends this request in my name from their pc)

    Any light you can throw on this problem of confusion would be much appreciated. I'd rather not have to uninstall and reinstall Firefox if possible.

    If the only option is to uninstall Firefox and reinstall from your site, I'm also in trouble (I can not see the internet or download).
    In this case, would you be able to send the .exe file as an attachment to my e-mail address? In the affirmative, please let me know and I'll give you more details.

    Thanks in advance.

    One possible cause is security software (firewall) that blocks or limits Firefox or plugin-container process without informing you, possibly after the detection of changes (update) for the Firefox program.

    Delete all rules for Firefox in the list of permissions in the firewall and leave your firewall again ask permission to get full unlimited access to the internet for Firefox and the plugin-container and the update process.

    See:

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions of the origin of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • [Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an auto update that's simple to install, just get this error every time

    [Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an automatic update that's simple to install, just get this error at each time HHHHEEEELLLPPPPP! Thank you

    I had the same problem.  But finally found a solution.  If your listing is similar to mine, then keep.  XP Media Center Edition 2005 (sp2).  AMD Athlon 64 x 2 Dual-Core, HP a1630n desktop computer.

    Go to the HP website, search for sp37394-XP sp3 Upgrade utility Microsoft for systems equipped with AMD processors.

    I had the same 0 x 80240036, 0x8024400a error, but realize my problem was really get manually downloaded sp3 and installed without continue loop crashing and not error messages.

  • I have a mess of error. about microsoft Isatap adapter... plug and play id root\ * Isatap\0002 error tv-configmgrerr31 need help with drivers

    need help with this.is there a link for the drivers. The only changes to my system is a new modom.netgear wireless g54.thank you

    Hello

    (1) what is the complete error message you receive?

    (2) when exactly you get this error message?

    (3) how long have you been faced with this problem?

    You can ignore this error message. This error message does not indicate a problem with the adapter. The adapter will continue to function correctly.

    See the article below

    On a Windows Vista-based computer or on a Windows Server 2008-based computer, the Microsoft ISATAP map appears with a yellow exclamation mark next to it in Device Manager, and you also receive an error message
    http://support.Microsoft.com/kb/932520

  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • Hi, I need help with my flash mp3 player

    Hi, I need help with my mp3 player, I wan't to add the pause button... Can you help me?

    I created the button I added btn_pause and it won't work.

    function soundStatus() {}

    var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded () / _root.sound_mc.sound_obj.getBytesTotal ();

    _root. Loader.loadBar._width = amountLoaded * 260;

    duration = _root.sound_mc.sound_obj.duration;

    position = _root.sound_mc.sound_obj.position;

    _root.playHead._x = position / duration * 272 + 5;

    }

    btn_play.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_pause.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj.pause ();

    };

    btn_stop.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj. Stop();

    };

    btn_fw.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == songfile.length - 1)? _Global.song_nr = 0: _global.song_nr ++;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_rev.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == 0)? _Global.song_nr = songfile. Length-1:-_global.song_nr;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

    < proposed by the mod to as3 - kglad >

    :

    function soundStatus() {}

    var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded () / _root.sound_mc.sound_obj.getBytesTotal ();

    _root. Loader.loadBar._width = amountLoaded * 260;

    duration = _root.sound_mc.sound_obj.duration;

    position = _root.sound_mc.sound_obj.position;

    _root.playHead._x = position / duration * 272 + 5;

    }

    btn_play.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_pause.onRelease = function() {}

    clearInterval (timeInterval);  you must re - set interval when the unpause button is clicked

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj. Stop()

    };

    {btn_unpause.onRelease = Function ()}

    This._parent.sound_mc.sound_obj. Start(position/1000);

    }

    btn_stop.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    This._parent.sound_mc.sound_obj. Stop();

    };

    btn_fw.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == songfile.length - 1)? _Global.song_nr = 0: _global.song_nr ++;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

    btn_rev.onRelease = function() {}

    clearInterval (timeInterval);

    _root.timeDisplay_txt. Text = "00:00 / 00:00 ';

    (song_nr == 0)? _Global.song_nr = songfile. Length-1:-_global.song_nr;

    _root.sound_mc.songStarter (songfile [song_nr]);

    };

  • Need help with video scrolling

    Hello

    I need help with a project. Subsequently, I want is that a webcam controls the position of the mouse and the mouse position

    control of a video. But I would like the part where the mouse position controls the video.

    So, if the mouse is on the left on your screen, the video will be on the first image and when you move, you're the mouse for

    the right to the video play as a result traffic. and stop when the mouse is completely right.

    Effectivly the scrolles from the mouse through the video. It must be on the x-axis.

    I'm not that formilliar with flash, so any help would be great

    THX!

    Thijs

    what you need to do, is to designate a rectangle where users can use their mouse to scroll through the video.  If this rectangle has instance name bar, you can use:

    var m, b:Number;

    var lastSeek:int = getTimer();

    flv_pb.addEventListener (MetadataEvent.METADATA_RECEIVED, f);

    bar.addEventListener (MouseEvent.MOUSE_MOVE, moveF);

    function f(e:MetadataEvent):void {}

    paramF (0,0,stage.stageWidth,e.info.duration);

    }

    function moveF(e:MouseEvent):void {}

    {if (getTimer () - lastSeek > 1000)}

    flv_pb. Seek(m*e.stageX+b);

    lastSeek = getTimer();

    flv_pb. Play();

    }

    }

    function paramF(x1:Number,y1:Number,x2:Number,y2:Number):void {}

    m = (y2 - y1) / (x 1 - x 2);

    b = y1 - m * x 1;

    }

  • Need help in a loop

    Hello everyone
    I need help with loop for
    in pl/sql, I see that we do have to give County loop increment for
    However if I want to increment suppose 2 so what to do
    I want to print an own of stars using the loop
    Like this
             *
          * * *
       * * * * *
     * * * * * * *
    However, I am able to print at a right angle triangle
    *
    **
    ***
    ****
    *****
    ******
    begin
    for i in 1..10
    loop
     for j in 1..i
      loop
     dbms_output.put('*');
     dbms_output.put(' ');
     end loop;
     dbms_output.put_line('');
     end loop;
     
        end ;
    Published by: Sara on November 22, 2010 03:28

    Published by: Sara on November 22, 2010 03:37

    Published by: Sara on November 22, 2010 03:37

    Published by: Sara on November 22, 2010 03:38
  • Need help with a declaration of 'IfThenIfNot '.

    Every year couple I need help with a script statement and these forums have been incredibly useful. Once more, I was hoping that someone out there had knowledge of something I am writing for a form, I need to automate:

    In the jargon of Excel that I try to write to would state so @if (("Subtotal"+"InvestigativeFee"+"PlanReviewFee") > 1000, + 100, + (("Sous-total" + "Investigativ Manar" + "PlanReviewFee") *. 1))

    What I have here is three form named subtotal, InvestigativeFee & PlanReviewFee fields.  The formula in question says it's a 'technology assessment fee"of 10% on the total part of what above mentioned 3 fields but there is a maximum charge of $100 for this tax.  The statement that I wrote above would have worked in Excel (not tested, but generally is the idea).  I was hoping someone mastering JavaScript could help me with a statement that I needed to do this work.

    Hope to hear from someone,

    Warmly yours.

    Steven L in Eugene OR

    Try the following in the custom calculation of the fresh field of evaluation script:

    Custom calculation script

    (function () {}

    Maximum package

    var max_taf = 100;

    Get the values of the field as numbers

    var v1 = + getField("Subtotal").value;
    var v2 = + getField("InvestigativeFee").value;
    var v3 = + getField("PlanReviewFee").value;

    Calculation of tax

    TAF var = (v1 + v2 + v3) / 10;

    Set this field to royalty calculated value if less than maximum, otherwise the maximum value

    Event.Value = (taf< 100)="" taf="" :="">

    })();

  • Need help with Sprite´s. (Rectangles and circle)

    Hello!

    I kinda need help with a project. I m supposed to do a script that responds to a click and moves the circle of one rectangle to another.

    (Here's a picture)

    howtosprite.JPG

    So, what I want is: when I click on the blue rectangle to the right, the circle must move instantly in the rectangle on the right. And same thing on the opposite path.

    Thanks in advance!

    -Best regards,.

    Aleksandar "Dyxir" B.

    import flash.events.MouseEvent;

    leftRec.addEventListener (MouseEvent.CLICK, fCircle);
    rightRec.addEventListener (MouseEvent.CLICK, fCircle);

    function fCircle(evt:MouseEvent)
    {
    Circle.x = evt.currentTarget.x;
    Circle.y = evt.currentTarget.y;
    }

    Note: Point for all alignment: Center

  • Need help with this gallery of xml!

    I have build a gallery but its very simple... There are pictures of the xml file.

    I have attached all the zip files.

    I just want two things if anyone can help.

    first of all when I press the next button, he's going to the next image, but without effect. It just displays the following image... I want to incorporate the effect of dragging when the image is changed to another.

    and secondly, I want to use the AutoPlay feature.

    Once swf starts images came one by one with a vertical drop of a few seconds.

    Thanks in advance... I really need help with this..!

    For the look of sliding effect using the actionscript class Tween.  Allows you to create motion tweens using the code.  The example below will be tween property _x of the instance named anObject from 0 to 300 in 3 seconds...

    import classes before using

    Import mx.transitions.Tween;
    Import mx.transitions.easing.Regular;

    TW var = new Tween (anObject, "_x", Regular.easeIn, 0, 300, 3, true);

    To implement an enforcement function auto you need to import all the images first, in the order, then you will need to use form any controlled timer, such as setInterval (with clearInterval not to need) in order to have things turn on automatically by some part-time

  • I need help with the control of two .swf in third.

    Hi, thanks for reading!

    I need help with the control of two .swf in third.

    I have a problem when I need to use a .swf in a digital signage solution, but were advised by the Legal Department, it cannot be changed in any way, I can not also have the source file blah blah blah. I pulled the .swfs on their site and I decompiled to see what I was up against.

    The main SWF that I need control is HCIC.swf and the problem is that it starts with a preloader, which, after the loading stops on a framework that requires user input to (button) on a play button, until the film will proceed and replay.

    What I've done so far is to create a SWF container, HCIC_container.swf, which will serve as a target for the HCIC.swf and I would like to send actionscript in the file, I am not allowed to edit.

    I managed to get done with help from someone on another forum. It is my hope that the following script just start HCIC.swf a framework after the preloader and button play and just play through.

    var container: MovieClip = createEmptyMovieClip ("container", getNextHighestDepth());
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.addListener (this);
    mcLoader.loadClip ("MCIC.swf", container);

    function onLoadInit(mc:MovieClip) {}
    mc.gotoAndPlay (14);
    }

    But unfortunately it does not solve my problem. Because there is a media - controller.swf, which is charged by HCIC.swf who has orders, including the play button to start HCIC.swf.

    Here is a link to a .zip with all 3 files .swf file and all 3 .fla files.

    http://www.axiscc.com/temp/HCIC.zip

    What I have to do is to automatically start the HCIC.swf file, bypassing the pre-loader and play button without having to edit it or in the media - controller.swf in any case. Thus, all scripts must be done in HCIC_container.swf.

    I know it is confusing and it is difficult to explain, but if you look at the files it must make sense.

    ActionScripting is far from my point hard, so I'm definitely over my head here.

    Thanks for your help.

    Got my solution on another forum.

    http://www.ActionScript.org/forums/showthread.php3?t=146827

Maybe you are looking for

  • How can I read items in four tables and store them in variables?

    Greetings, I have 4 tables which I read to control an autonomous robot vehicle as instructions. I must be able to read the first elements of each table and store in separate variables 4 (direction, speed, angle, distance). Wait until the first statem

  • blue screen on PC minitour Convertible HP Compaq 8000 Elite

    It is a new computer purchased from OfficeMax and just put in service on January 4, 2014.  I get monitor outages, with the error code display driver stopped responding and has.  It's a nuisance, but all of a sudden I'm getting a blue screen crash as

  • Pavilion p7-1421: useless recovery disks

    Restore disks, I created just after I bought this computer are useless, as well as the recovery hard disk partition.  In order to restore my computer after a system crash, I needed to take it to a shop to have Windows reinstalled at a cost of $100.  

  • CD drive is not displayed under 'computer '.

    I put a CD in my CD drive and nothing happened. I use Windows 7. The PC is HP pavilion slimline. I clicked on the computer and the CD drive does not appear. Help! All I want to do is instlal a program from a CD. Thank you

  • Creative PS helps cloud

    I tried to download PS in my cloud creative but said that I already have and it is not on my computer?