Statement error in for loop noobq

Hi
Could anyoe tell me why this wont work? Its supposed to count upp to tal in the first one and then count down from tal in the second and its the second one that dont work. I get a statement error for the text i put in between stars (supposed to be bold but i dont know..)
thanks
class r?knaa {
    public static void main(String[] args) {
        new r?knaa().run();
    void run() {
     int tal = Keyboard.nextInt ("Ange ett tal ? s? ska vi r?kna...(^_^): ");
     for (int upp = 1; upp <= tal; upp = upp + 1) {
         System.out.print ( upp+ " " );
     System.out.println (" ");
     System.out.println (" ");
     for (*tal*; tal > 0; tal = tal -1 ){
         System.out.print ( tal+ " " );
}Edited by: gibitlib on Feb 19, 2010 3:02 PM

jverd wrote:
sharkura wrote:
I assumed that it would decrement after the block of statements associated with the while loop, as is true with the for loop.Not sure what you mean by "as is true with the for loop", but I'm catching a hint of a very common misconception about the post-inc/dec operators.
A LOT of people think that post-inc/dec means "last step in the statement" or "after everything else has been done" or something like that. That kind of thiiking is just black magic hocus pocus and serves no purposeI don't think I thiik like that, Jeff. I've never used a post-inc operator in a while loop. Certainly, if I felt a need to do so, I would test it, and try to understand why it works the way it does. Empirically, I know that given the following for loop:
for ( int i = 0; i < limit; i++ )
  ... some statements
}the incrementation of i occurs after the statements in the block execute. It may be specific to the for loop that the third statement in the for loop executes after the block of statements, in which case
for ( int i = 0; i < limit; ++i )
  ... some statements
}would work the same, and you can bet I will test that.
I did make an assumption last night, and did not test it. That is not typical of me. I do resent somewhat the accusation of black magic hocus pocus. My last statement in that post was:
sharkura wrote:
I'll have to play with this some.Implicit in that remark was my intent to read more about pre/post decrementation and experiment until I more fully understood it. You have pointed out my lack of complete understanding, and, odd as it may seem, I appreciate that. I do log into these forums, partly, to improve my understanding of java.
{?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Select statement in a for loop

    Hi all,
    Can a select stmt be used in the body of the for loop/ nested for loop ?
    I tries using (even if its very simple for loop) it gives the following error
    PL/SQL: ORA-00933: SQL command not properly ended...
    code is
    DECLARE
    CURSOR C1 is select 'Monday'  from dual
    union all
    select 'Tuesday' from dual
    union all
    select 'Wednesday' from dual
    union all
    select 'Thursday' from dual
    union all
    select 'Friday' from dual
    union all
    select 'Saturday' from dual
    union all
    select 'Sunday' from dual;
            type rec_info is record
            name varchar2(20),
            FNAME varchar2(20),
            LNAME varchar2(20)
            type ty_info is table of rec_info;
            info ty_info;
            type rec_abc is record
            day varchar2(3000)
            type ty_abc is table of rec_abc;
            abc ty_abc;
            Cursor C2 is
            select t.name, u.first_name, u.last_name
            from territories t, users u, territories_users tu
            where t.ID = tu.TERRITORY_ID
            and tu.USER_ID = u.ID ;
    BEGIN
    OPEN C1;
    Loop
    FETCH C1 into abc;
    EXIT when C1%notfound;
    DBMS_OUTPUT.PUT_LINE(abc);
    END LOOP;
    CLOSE C1;
    OPEN C2;
    FETCH C2 BULK COLLECT into info;
    CLOSE C2;
           for i in info.first .. info.last
           LOOP
                       for j in abc.first .. abc.last
                       LOOP
                              select --info(i).name, info(i).FNAME, info(i),LNAME,'AM' "AM/PM",
                            to_char(c.name)||' '||ct.PRIMARY_ADDRESS_CITY||','||ct.PRIMARY_ADDRESS_STATE||','||ct.PRIMARY_ADDRESS_COUNTRY
                           from
                            territories t, territories_users tu,
                            users u, calls_users cu, calls c, 
                            calls_contacts cc, contacts ct    
                            where
                            tu.TERRITORY_ID = t.id
                            and t.name = info(i).name
                            and u.first_name = info(i).FNAME
                            and u.last_name = info(i).LNAME
                          and (c.date_start between trim(next_day(sysdate,abc(j).day)) and trim(next_day(sysdate,abc(j).day)))
                            and tu.USER_ID = u.id
                            and cu.USER_ID = u.id
                            and cu.CALL_ID = c.id
                            and to_char(c.time_start,'hh24') < '12'
                            and cc.CALL_ID = c.ID
                            and cc.CONTACT_ID = ct.id
                            and rownum < 2
                     END LOOP;
         END LOOP;
    END;

    "Can a select stmt be used in the body of the for loop/ nested for loop "
    Yes.... but with an INTO part.....
    select c1 , c2 , c3 into var1 , var2 , var3 from table1
    Sim

  • Error in for loop

    I have this small code snippet but its always giving errors. I have included the java.util.Random package in the import statement as well
            for (int i = 0; i < 100; i++)
                char c = (char) (Math.random() * 26 + ?a?);  // FIRST ERROR IS ON THIS LINE
                switch(c)
                case ?a?:
                case ?e?:
                case ?i?:
                case ?o?:
                case ?u?:
                    System.out.println(?Vowel?); break;
                case ?y?:
                case ?w?:
                    System.out.println(?Sometimes a vowel?); break;
                default:
                    System.out.println(?Not a vowel?);
            }What exactly is the problem i am unable to figure out?

    Hi, we probably share the share the same problem , any ideas please? i have try the code given in this post but with no success
    goldfish

  • PNA Guided Calibration: GPIB write error in for loop

    Hi,
    I have a LabVIEW program that creates a Guided Power Calibration on a PNA.
    After initializing everything properly, I have a for loop that loops through all the manual steps that the user must go through (ex: Connect Channel A of Power meter to Port 1" "Connect male Short to port 1" etc).
    The problem is, the program displays an error at the first command: sens:corr:coll:guid:acq STAN1
    I says there is an error with the GPIB Write function.
    Here are the commands I send:
    SYSTRES
    DISPlay:WINDow2TATE ON
    CALCulate2ARameterEFine:EXT 'MyMeas',S21
    DISPlay:WINDow2:TRACe1:FEED 'MyMeas'
    CALC1AREL 'CH1_S11_1'
    SENS:FREQTAR 2e9
    SENS:FREQTOP 4e9
    SENSWEOINTS 3
    SENS:CORR:COLL:GUID:CONNORT1 'APC 2.4 male'
    SENS:CORR:COLL:GUID:CONNORT2 'APC 2.4 male'
    SENS:CORR:COLL:GUID:CKITORT1 '85056D'
    SENS:CORR:COLL:GUID:CKITORT2 '85056D' 
    SENSe:CORRection:COLLect:GUIDedSENsor1 ON
    SYSTem:COMMunicateSENsor gpib, "13"   
    SENSe:CORRection:COLLect:GUIDedSENsor1OWer:LEVel -20
    sens:corr:coll:guid:init
    sens:corr:coll:guid:steps?
    //for loop from 1 to total_number_of_steps
    sens:corr:coll:guid:desc? <step#>
    sens:corr:coll:guid:acq STAN<step#>
    The program quits right at the first step, when I send "sens:corr:coll:guid:acq STAN1", although the command is executed.
    Also, the VBScript with the same commands works fine.
    Can anybody help me? I've been stuck for a while now.
    I attached the block diagram of the for loop.
    Thanks in advance,
    Nicolas
    Attachments:
    Guided cal for loop.vi ‏27 KB

    Sending SENS:corr:coll:guid:acq STAN1 \n gives me a different error: -101 "Invalid Character".
    From my different attempts at figuring this out, I thought the problem would come from LabVIEW, since the vbscript with the same commands works on the PNA.
    I also modified the for loop because I thought each iteration should be linked to the previous one with the error wire (see attached).
    I still have the same issue, only the first iteration is executed, then the program quits.
    Attachments:
    Guided cal for loop.vi ‏28 KB

  • Logic error in for loop

    I have a JSP form which list modules that student can take. Some of these modules have prerequisite and some do not.
    In order to successfully register a student, I have a number of requirements e.g. must not be already register; the registration date must not have passed etc.
    My problem is in my code logic. For example, when a student selects a module, which does not have a prerequisite, and a module, which has a prerequisite and click on the Register button, an Error.jsp page is displayed because he has not satisfied the prerequisite for the second module.
    What the program does is that it registers the first module which dose not has a prerequisite and display the Error.jsp page.
    This is confusing for the user because they expect to do the process again and do not know that the first module has been register successfully.
    Here is my code
    private int enroll()throws SQLException,IOException
          // Get the check box values
          String checkboxNames[] = request.getParameterValues( "checkbox" );
          moduleVector = (Vector) session.getAttribute( "moduleVector" );
          //Get the student bean
          studentBean = (StudentBean) session.getAttribute( "studentBean" );
          boolean isEnrolled = false;
          String studentId = studentBean.getStudentId();
          int maxModule = Integer.parseInt(studentBean.getMaxModule());
          for (int i = 0; i < checkboxNames.length; i++) {
            String moduleId = checkboxNames;
    // First, make sure that this student is not already
    // enrolled for this module, and he/she has never
    // taken and passed the module before.
    isEnrolled = srsBean.isEnrolledIn( moduleId, studentId );
    if (isEnrolled){
    session.setAttribute("pre_enrolled", moduleId);
    return PREVIOUSLY_ENROLLED;
    // Now we make sure that the registration date has not
    // already passed
    Calendar rightNow = Calendar.getInstance();
    int rightNowMonth = rightNow.MONTH;
    int rightNowDay = rightNow.DAY_OF_MONTH;
    if ( rightNowMonth > Constants.REGISTER_DATE_MONTH ) {
    return PASSED_REGISTER_DATE;
    }else if( rightNowMonth == Constants.REGISTER_DATE_MONTH ) {
    if ( rightNowDay > Constants.REGISTER_DATE_DAY ) {
    return PASSED_REGISTER_DATE;
    int noModule = srsBean.noModuleEnrolledIn( studentId );
    // Now we make sure we don't erroll student on more
    // modules that the are allowed to do.
    if (!(noModule < maxModule)){
    // convert maxModule into string so we can use setAttribute
    String max = String.valueOf(maxModule);
    session.setAttribute("exceed_max_no", max);
    return EXCEEDED_MAX_NO_MODULE;
    // if there are any prerequisites for this module, check
    // to ensure that the student has completed them.
    if ( srsBean.hasPrerequisites(moduleId)) {
    Enumeration e = srsBean.getPrerequisites(moduleId);
    while ( e.hasMoreElements() ) {
    String pre = (String) e.nextElement();
    // See if the Student's Transcript reflects
    // successful completion of the prerequisite.
    if (!srsBean.verifyCompletion(moduleId, studentId)){
    session.setAttribute("prereq_not_sat", moduleId);
    return PREREQ_NOT_SATISFIED;
    // if we made it to here in the code, we're ready to
    // officially enroll the student.
    srsBean.enroll( studentId, moduleId );
    return SUCCESSFULLY_ENROLLED;
    How can i fix this problem ?

    1. well first check whether all modlues can be registered..
    2. you need to remove that in your for loop
    srsBean.enroll( studentId, moduleId );
    3. if all conditions are satisfied.
    for (int i = 0; i < checkboxNames.length; i++) {       
      String moduleId = checkboxNames<i>;
      srsBean.enroll( studentId, moduleId );
    }4. put the above code before
    return SUCCESSFULLY_ENROLLED;

  • Handle Error in for Loop and finish the iteration

    I am using a for Loop now i encounter an error.
    i want to handle this error but after that carry on with iteration of the loop.
    Any Parallel to "Continue" in JAVA or any other solution for this...
    Please Suggest.

    You can use pl/sql block with exception inside the loop
    Re: Continue beyond expcetion in proc...
    Message was edited by:
    jeneesh

  • State Diagram inside For Loop

    I created a fairly involved for-loop with a flat sequence inside of it.  The sequence had about four events that occured, and since it was kind of ugly, I thought I'd try the State Diagram Toolkit to replace the majority of the code.  When I selected state diagram from the pallete, I was outside my for-loop.  I drew up the various states/transitions, then realized that all this code needed to be inside the for-loop, but LV won't let me place state diagram-generated code inside the for-loop.  I select everything related to the state diagram, but when I drag into the for-loop, only the comments come inside.  I even tried generating a new for-loop and placing the state code inside.  No luck. Any thoughts?

    "Any thoughts?"
    Yes but not any that will help.
    1) Just modify your SD so that the exit loops back to the start while there are still things to do. Forget the outer For loop.
    2) THe observations you reported are correct. When I first discovered these limitiations I said "That sucks!". Since then I have learned a bit and have grown to love the SDE.
    The SDE is JUST (note: "just" is a four letter word around here ) a LV application that ofers a very limited GUI consisting of a picture control that then scripts (see LAVA Scripting Forum for info on scripting) your SD for you. SCripting LV code is no easy task. My experiments with scripting has shown that I have to keep a database of the contents of the LV diagram my code is developing to keep track of what is where. Well it turns out that the structure of a LV diagram is a lot like the structure of a FP in that you start with a "root" object either the FP or the BD. THe BD then has structures on it, like seq's loops etc with unlited nesting possible.
    Now the SD created by the SDE is really just a fancy while loop with an case structure and code to support the driving enum. In order for you to be able to edit the SD the SDE needs to know what is htere already so it can show the diagram. It "KNOWS" by looking at its internal DB (I believe is stored inside of VI along with the enum.ctl) of the SD. To keep the DB updated, the SDE must be used to manipulate the SD.
    Stop rambling and guessing and get to the point!
    Moving the SD is just not supported by the SDE so it can not be done. To do so would require the SDE be able to "look" at the diagram, and repeat all of its work in the new location in the diagram.
    BTW: Thank you for trying out and asking about the SDE. the more talking we do on this subject, the sooner the SDE will be updated.
    My SDE wishlist (partial)
    Add comments to diagram from SDE screen.
    Add data structures to SD (shift registers) from SDE screen.
    Add "un-do".
    Select multiple objects on SDE screen and move or allign.
    Select multiple objects on SDE screen and do "create sub-State-Diagram".
    Allow watching more than one SDE in execution highlighting at the same time.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Syntax error in For Loop statement

    Hello
    Normally my FOR staements have not been a problem as only access one table. I the example below I am accessing three table and therefore I get a Syntax error.
    I only wish to select the "Product" recored but need the other table to enable the select the right results.
    FOR product_rec IN (SELECT * from PRODUCT, PRODUCT_GROUP,PROD_PROD_GROUP
    where PRODUCT_GROUP.PRODUCT_GROUP_KEY = PROD_PROD_GROUP.PRODUCT_GROUP_KEY
    and PROD_PROD_GROUP.PRODUCT_KEY = PRODUCT.PRODUCT_KEY
    and product.supplier_key = company_no
    and PROD_PROD_GROUP.MULTI_WEB_DIS = 1
    order by PROD_PROD_GROUP.MULTI_WEB_SEQ)
    Can anyone let the correct syntx for this statement.
    Thanks
    Pete

    Like Dom said:
    FOR product_rec IN (SELECT PRODUCT.* from PRODUCT, PRODUCT_GROUP,PROD_PROD_GROUP
    where PRODUCT_GROUP.PRODUCT_GROUP_KEY = PROD_PROD_GROUP.PRODUCT_GROUP_KEY
    and PROD_PROD_GROUP.PRODUCT_KEY = PRODUCT.PRODUCT_KEY
    and product.supplier_key = company_no
    and PROD_PROD_GROUP.MULTI_WEB_DIS = 1
    order by PROD_PROD_GROUP.MULTI_WEB_SEQ) Or what he meant by "nice to have", use aliases:
    select p.*
    from
      product p,
      product_group pg,
      prod_prod_group ppg
    where
      pg.product_group_key = ppg.product_group_key
      and ppg.product_key = p.product_key
      and p.supplier_key = company_no
      and ppg.multi_web_dis = 1
    order by
      ppg.multi_web_seqAlso, note that company_no is not aliased in the above query. If this is a column, it should be aliased as well (either with the full table name or the alias if you switch to using them). If it is a PL/SQL variable, it is fine as is.
    Edited by: cmartin2 on Feb 2, 2011 1:56 PM

  • WLST script is throwing errors under for loop

    I'm new to wlst and getting the below errros while running the script. the name variable within cd command does not replaced with right value and abort the error. I would appropriate if some can point me to right direction.
    cat serverName2.py
    connect('test','test123','t3://test-app-dev-a:12619')
    domainRuntime()
    svrs = adminHome.getMBeansByType('Server')
    for s in svrs:
    name = s.getName()
    cd('/ServerRuntimes/'+'name')
    ls()
    disconnect()
    java weblogic.WLST serverName2.py
    getting the below errors
    Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
    For more help, use help(domainRuntime)
    No stack trace available.
    Problem invoking WLST - Traceback (innermost last):
    File "<iostream>", line 170, in cd
    WLSTException: 'Error cding to the MBean'

    You should remove quotes for name.
    cat serverName2.py
    connect('test','test123','t3://test-app-dev-a:12619')
    domainRuntime()
    svrs = adminHome.getMBeansByType('Server')
    for s in svrs:
    name = s.getName()
    cd('/ServerRuntimes/'+ name )
    ls()
    disconnect()
    Thanks,
    Krishna.

  • Replace the following open/fetch/close statements with a cursor FOR loop

    Hi anyone could you please help me,
    I would like to replace the following open/fetch/close statements with a cursor FOR loop.
    Codes are:
    CREATE OR REPLACE PROCEDURE COMOES.orchid_shipment_interface IS
      -- get the com shipment header records
      CURSOR c_com_shphdr ( p_dwn_end_dt DATE ) IS
      SELECT custno client_id
           , plheadno plheadno
           , DECODE(carr_no,'FEDX',lading_no,'UPS',lading_no,carrier_pro_no) tracking_no
           , carr_no||'/'||carr_method carrier_id
           , plantid plant_id
           , carr_no
           , lading_no
           , del_custaddr ship_to_id
           , ol_type cfm_order_type
           , del_custno
           , shipterm    freight_terms
           , del_custattn attn_line
           , custaddr
        FROM com_plhead@com_pricing.world
       WHERE status = '9'
         AND (mod_dat) > p_dwn_end_dt;
      -- get the com shipment address records
      CURSOR c_com_shpadr (p_custaddr VARCHAR2) IS
      SELECT name1 addr_name
           , street1 addr_line1
           , street2 addr_line2
           , city city
           , state state_cd
           , zip zip
           , country country_cd
           , phone work_phone
           , email email1
        FROM com_address@com_pricing.world
       WHERE addr_id = p_custaddr;
      -- get the com shipment detail records
      CURSOR c_com_shpdtl ( p_plheadno NUMBER) IS
      SELECT pll.plheadno pllheadno
           , pll.pllineno ord_line_no
           , pll.ol_no erp_line_no
           , pll.ol_segno
           , pll.fg_id sku
           , pll.qty_shipped ship_qty
           , pll.ordno erp_ord_no
           FROM com_plline@com_pricing.world pll
       WHERE pll.plheadno = p_plheadno
         AND NOT EXISTS (SELECT '1'
                           FROM com_pkg_int_interface@com_pricing.world  cpi
                          WHERE pll.ordno = cpi.ordno
                            AND pll.ol_no = cpi.ol_no);
      -- type declaration
      -- type declaration of com table.
      TYPE t_com_shphdr IS TABLE OF c_com_shphdr%ROWTYPE INDEX BY BINARY_INTEGER;
      TYPE t_orchid_shphdr IS TABLE OF orchid_shipment_hdr_intf%ROWTYPE INDEX BY BINARY_INTEGER;
      TYPE t_com_shpadr IS TABLE OF c_com_shpadr%ROWTYPE INDEX BY BINARY_INTEGER;
      TYPE t_orchid_shpadr IS TABLE OF orchid_shipment_address_intf%ROWTYPE INDEX BY BINARY_INTEGER;
      TYPE t_com_shpdtl IS TABLE OF c_com_shpdtl%ROWTYPE INDEX BY BINARY_INTEGER;
      TYPE t_orchid_shpdtl IS TABLE OF orchid_shipment_dtl_intf%ROWTYPE INDEX BY BINARY_INTEGER;
      lv_company_code       com_customer.business_unit%TYPE;
      lv_erp_ord_no         com_plline.ordno%TYPE;
      lv_actual_ship_date   com_plline.confirm_date%TYPE;
      lv_po_no              com_oline.po_no%TYPE;
      lv_ord_date           com_oline.entrydate%TYPE;
      lv_hdr_batch_ctrl_no  download_batch_info.batch_ctrl_no%TYPE;
      lv_adr_batch_ctrl_no  download_batch_info.batch_ctrl_no%TYPE;
      lv_dtl_batch_ctrl_no  download_batch_info.batch_ctrl_no%TYPE;
      lv_sku_desc           com_salesitem.title%TYPE;
      lv_ord_qty            com_oldelseg.qty%TYPE;
      lr_com_shphdr    t_com_shphdr;
      lr_orchid_shphdr t_orchid_shphdr;
      lr_com_shpadr    t_com_shpadr;
      lr_orchid_shpadr t_orchid_shpadr;
      lr_com_shpdtl    t_com_shpdtl;
      lr_orchid_shpdtl t_orchid_shpdtl;
      -- variable declaration
      ln_shphdr_seq    NUMBER(10):= 0;
      ln_shpadr_seg    NUMBER(10):= 0;
      ln_shpdtl_seq    NUMBER(10):= 0;
      cnt              NUMBER(10):= 0;
      cnt1             NUMBER(10):= 0;
      ld_hdr_dwn_end_dt           download_batch_info.download_end_tstamp%TYPE;
      lc_hdr_dwn_status           download_batch_info.dwn_status%TYPE;
      ld_hdr_download_end_tstamp  DATE;
      ln_hdr_running_seq          NUMBER(10) := 0;
      ld_adr_dwn_end_dt           download_batch_info.download_end_tstamp%TYPE;
      lc_adr_dwn_status           download_batch_info.dwn_status%TYPE;
      ld_adr_download_end_tstamp  DATE;
      ln_adr_running_seg          NUMBER(10) := 0;
      ld_dtl_dwn_end_dt           download_batch_info.download_end_tstamp%TYPE;
      lc_dtl_dwn_status           download_batch_info.dwn_status%TYPE;
      ld_dtl_download_end_tstamp  DATE;
      ln_dtl_running_seq          NUMBER(10) := 0;
    BEGIN
      -- get the batch control number details from batch information table for shipment header
      BEGIN
        SELECT batch_ctrl_no
             , NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
             , dwn_status
          INTO lv_hdr_batch_ctrl_no
             , ld_hdr_dwn_end_dt
             , lc_hdr_dwn_status
          FROM comoes.download_batch_info
         WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF';
      EXCEPTION
        WHEN NO_DATA_FOUND THEN
          DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
          RAISE;
        WHEN TOO_MANY_ROWS THEN
          DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
          RAISE;
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
          RAISE;
      END;
      -- get the batch control number details from batch information table for shipment address
      BEGIN
        SELECT batch_ctrl_no
             , NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
             , dwn_status
          INTO lv_adr_batch_ctrl_no
             , ld_adr_dwn_end_dt
             , lc_adr_dwn_status
          FROM comoes.download_batch_info
         WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF';
      EXCEPTION
        WHEN NO_DATA_FOUND THEN
          DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
          RAISE;
        WHEN TOO_MANY_ROWS THEN
          DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
          RAISE;
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!'||SQLERRM);
          RAISE;
      END;
      -- get the batch control number details from batch information table for shipment details
      BEGIN
        SELECT batch_ctrl_no
             , NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
             , dwn_status
          INTO lv_dtl_batch_ctrl_no
             , ld_dtl_dwn_end_dt
             , lc_dtl_dwn_status
          FROM download_batch_info
         WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF';
      EXCEPTION
        WHEN NO_DATA_FOUND THEN
          DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
          RAISE;
        WHEN TOO_MANY_ROWS THEN
          DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
          RAISE;
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!'||SQLERRM);
          RAISE;
      END;
      -- if previous run is not sucess then do nothing and return.
      OPEN c_com_shphdr ( ld_hdr_dwn_end_dt ) ;
      LOOP
        -- delete the collection for every cycle
        lr_com_shphdr.DELETE;
        lr_orchid_shphdr.DELETE;
        lr_com_shpadr.DELETE;
        lr_orchid_shpadr.DELETE;
        lr_com_shpdtl.DELETE;
        lr_orchid_shpdtl.DELETE;
        -- fetch the order header records to collection
        FETCH c_com_shphdr BULK COLLECT INTO lr_com_shphdr LIMIT 500;
        -- where there is no record in the collection the exit from the loop
        EXIT WHEN lr_com_shphdr.COUNT = 0;
        -- build your logic there to populate the data into order header collection.
          FOR i IN 1..lr_com_shphdr.COUNT
          LOOP
            -- accumulate header running sequence number
            ln_hdr_running_seq := ln_hdr_running_seq + 1;
            ln_shphdr_seq      := ln_hdr_running_seq;
             -- Get the business unit for the customer from com_customer
            BEGIN
              SELECT business_unit
                INTO lv_company_code
                FROM com_customer@com_pricing.world
               WHERE custno = lr_com_shphdr(i).del_custno;
            EXCEPTION
            WHEN OTHERS THEN
              lv_company_code := NULL;
            END;
            -- Get the ordno, confirm_date from COM_PLLINE
            BEGIN
            SELECT ordno
                 , confirm_date
              INTO lv_erp_ord_no
                 , lv_actual_ship_date
              FROM com_plline@com_pricing.world cpl
             WHERE cpl.plheadno = lr_com_shphdr(i).plheadno
               AND ROWNUM = 1;
            EXCEPTION
            WHEN OTHERS THEN
              lv_erp_ord_no       := NULL;
              lv_actual_ship_date := NULL;
            END;
            -- Get the po_no, Entry_date from COM_OLINE
            BEGIN
              SELECT po_no
                   , entrydate
                INTO lv_po_no
                   , lv_ord_date
                FROM com_oline@com_pricing.world col
               WHERE col.ordno = lv_erp_ord_no
                 AND ROWNUM = 1;
            EXCEPTION
            WHEN OTHERS THEN
              lv_po_no    := NULL;
              lv_ord_date := NULL;
            END;
            -- To assign the Bol Number from Lading Number
            IF lr_com_shphdr(i).carr_no NOT IN ('FEDX','UPS') THEN
               lr_orchid_shphdr(i).bol_no     := lr_com_shphdr(i).lading_no;
            ELSE
               lr_orchid_shphdr(i).bol_no     := NULL;
            END IF;
            -- For each order header get the Shipment Delivery Adderss
            OPEN c_com_shpadr ( lr_com_shphdr(i).custaddr);
            FETCH c_com_shpadr BULK COLLECT INTO lr_com_shpadr;
            -- where there is no record in the collection the exit from the loop
            EXIT WHEN lr_com_shpadr.COUNT = 0;
            -- biuld your logic here to populate the del address collection.
              FOR j IN 1..lr_com_shpadr.COUNT
              LOOP
                -- accumulate the loop count into temp variable, so that will through tell each set of order header.
                cnt := cnt + 1;
                -- accumolate the header running sequence number.
                ln_adr_running_seg := ln_adr_running_seg + 1;
                ln_shpadr_seg := ln_adr_running_seg;
                -- move the order address data into collection.
                lr_orchid_shpadr(cnt).client_id       := lr_com_shphdr(i).del_custno;
                lr_orchid_shpadr(cnt).ord_no          := lr_com_shphdr(i).plheadno;
                lr_orchid_shpadr(cnt).tracking_no     := lr_com_shphdr(i).tracking_no;
                lr_orchid_shpadr(cnt).addr_name       := lr_com_shpadr(j).addr_name;
                lr_orchid_shpadr(cnt).attn_line       := lr_com_shphdr(i).attn_line;
                lr_orchid_shpadr(cnt).addr_line1      := lr_com_shpadr(j).addr_line1;
                lr_orchid_shpadr(cnt).addr_line2      := lr_com_shpadr(j).addr_line2;
                lr_orchid_shpadr(cnt).addr_line3      := NULL;
                lr_orchid_shpadr(cnt).addr_line4      := NULL;
                lr_orchid_shpadr(cnt).addr_line5      := NULL;
                lr_orchid_shpadr(cnt).city            := lr_com_shpadr(j).city;
                lr_orchid_shpadr(cnt).state_cd        := lr_com_shpadr(j).state_cd;
                lr_orchid_shpadr(cnt).zip             := lr_com_shpadr(j).zip;
                lr_orchid_shpadr(cnt).zip_ext         := NULL;
                lr_orchid_shpadr(cnt).country_cd      := lr_com_shpadr(j).country_cd;
                lr_orchid_shpadr(cnt).tax_geo_cd      := NULL;
                lr_orchid_shpadr(cnt).work_phone      := lr_com_shpadr(j).work_phone;
                lr_orchid_shpadr(cnt).email1          := lr_com_shpadr(j).email1;
                lr_orchid_shpadr(cnt).cre_dat         := SYSDATE;
                lr_orchid_shpadr(cnt).cre_usr         := USER;
                lr_orchid_shpadr(cnt).batch_ctrl_no   := lv_adr_batch_ctrl_no;
              END LOOP;
            CLOSE c_com_shpadr;
            -- For each order header get the order detail/delivery segment data
            OPEN c_com_shpdtl ( lr_com_shphdr(i).plheadno );
            FETCH c_com_shpdtl BULK COLLECT INTO lr_com_shpdtl;
            -- where there is no record in the collection the exit from the loop
            EXIT WHEN lr_com_shpdtl.COUNT = 0;
            -- build your logic here to populate the order detail collection
              FOR k IN 1..lr_com_shpdtl.COUNT
              LOOP
                -- accumulate the loop count into a temp variable, so that will through till each set of Order Header.
                cnt1 := cnt1 + 1;
                -- accumulate header running sequence number
                ln_dtl_running_seq := ln_dtl_running_seq + 1;
                ln_shpdtl_seq := ln_dtl_running_seq;
                -- Get Quantity for the delvery from delevery segment table.
                BEGIN
                  SELECT NVL(Qty,0)
                    INTO lv_ord_qty
                    FROM com_oldelseg@com_pricing.world cds
                   WHERE cds.ordno = lr_com_shpdtl(k).erp_ord_no
                     AND cds.ol_no = lr_com_shpdtl(k).erp_line_no
                     AND cds.ol_segno = lr_com_shpdtl(k).ol_segno;
                EXCEPTION
                  WHEN OTHERS THEN
                    lv_ord_qty := NULL;
                END;
                -- Get Title for the salesitem from the salesitem table.
                BEGIN
                  SELECT Title
                    INTO lv_sku_desc
                    FROM com_salesitem@com_pricing.world cs
                   WHERE cs.fg_id = lr_com_shpdtl(k).sku;
                EXCEPTION
                  WHEN OTHERS THEN
                    lv_sku_desc := NULL;
                END;
                -- move the Order detail data into collection
                lr_orchid_shpdtl(cnt1).client_id         := lr_com_shphdr(i).client_id;
                lr_orchid_shpdtl(cnt1).ord_no            := lr_com_shphdr(i).plheadno;
                lr_orchid_shpdtl(cnt1).ord_line_no       := lr_com_shpdtl(k).ord_line_no;
                lr_orchid_shpdtl(cnt1).erp_line_no       := lr_com_shpdtl(k).erp_line_no;
                lr_orchid_shpdtl(cnt1).sku               := lr_com_shpdtl(k).sku;
                lr_orchid_shpdtl(cnt1).tracking_no       := lr_com_shphdr(i).tracking_no;
                lr_orchid_shpdtl(cnt1).container_no      := NULL;
                lr_orchid_shpdtl(cnt1).ord_qty           := lv_ord_qty;
                lr_orchid_shpdtl(cnt1).ship_qty          := lr_com_shpdtl(k).ship_qty;
                lr_orchid_shpdtl(cnt1).price_point       := NULL;
                lr_orchid_shpdtl(cnt1).pick_invoice_no   := NULL;
                lr_orchid_shpdtl(cnt1).cancel_qty        := NULL;
                lr_orchid_shpdtl(cnt1).bldg_id           := NULL;                              --lr_com_shpdtl(k).bldg_id;
                lr_orchid_shpdtl(cnt1).sku_company       := NULL;                              --lr_com_shpdtl(k).sku_company;
                lr_orchid_shpdtl(cnt1).sku_desc          := lv_sku_desc;
                lr_orchid_shpdtl(cnt1).icc_cd1           := NULL;                              --lr_com_shpdtl(k).icc_cd1;
                lr_orchid_shpdtl(cnt1).erp_ord_no        := lr_com_shpdtl(k).erp_ord_no;
                lr_orchid_shpdtl(cnt1).cre_dat           := SYSDATE;
                lr_orchid_shpdtl(cnt1).cre_usr           := USER;
                lr_orchid_shpdtl(cnt1).batch_ctrl_no     := lv_dtl_batch_ctrl_no;
              END LOOP;
            CLOSE c_com_shpdtl;
            -- build the logic to populate Order Header
            lr_orchid_shphdr(i).client_id              := lr_com_shphdr(i).client_id;
            lr_orchid_shphdr(i).ord_no                 := lr_com_shphdr(i).plheadno;
            lr_orchid_shphdr(i).tracking_no            := lr_com_shphdr(i).tracking_no;
            lr_orchid_shphdr(i).container_no           := NULL;                            -- container number is not maintained in COM
            lr_orchid_shphdr(i).carrier_id             := lr_com_shphdr(i).carrier_id;
            lr_orchid_shphdr(i).plant_id               := lr_com_shphdr(i).plant_id;
            lr_orchid_shphdr(i).erp_ord_no             := lv_erp_ord_no;
            lr_orchid_shphdr(i).erp_ord_no2            := NULL;
            lr_orchid_shphdr(i).po_no                  := lv_po_no;
            lr_orchid_shphdr(i).ship_to_id             := lr_com_shphdr(i).ship_to_id;
            lr_orchid_shphdr(i).ship_to_addr_id        := lr_com_shphdr(i).custaddr;
            lr_orchid_shphdr(i).scac                   := NULL;                             --lr_com_shphdr(i).scac;
            lr_orchid_shphdr(i).actual_ship_date       := lv_actual_ship_date;
            lr_orchid_shphdr(i).cfm_order_type         := lr_com_shphdr(i).cfm_order_type;
            lr_orchid_shphdr(i).company_code           := lv_company_code;
            lr_orchid_shphdr(i).no_of_order_lines      := NULL;                             --lr_com_shphdr(i).no_of_order_lines;
            lr_orchid_shphdr(i).pick_invoice_no        := NULL;
            lr_orchid_shphdr(i).ord_date               := lv_ord_date;
            lr_orchid_shphdr(i).orig_tender_date       := NULL;
            lr_orchid_shphdr(i).orig_delv_date         := NULL;
            lr_orchid_shphdr(i).delivery_flag          := NULL;
            lr_orchid_shphdr(i).delv_date_from         := NULL;
            lr_orchid_shphdr(i).delv_date_to           := NULL;
            lr_orchid_shphdr(i).orig_carr_cd           := NULL;
            lr_orchid_shphdr(i).routing_comment        := NULL;
            lr_orchid_shphdr(i).segment_type           := NULL;
            lr_orchid_shphdr(i).back_order_flag        := NULL;
            lr_orchid_shphdr(i).addr_override_flag     := NULL;
            lr_orchid_shphdr(i).fmx_assigned_carr      := NULL;
            lr_orchid_shphdr(i).fmx_assigned_ship_date := NULL;
            lr_orchid_shphdr(i).fmx_assigned_delv_date := NULL;
            lr_orchid_shphdr(i).freight_terms          := lr_com_shphdr(i).freight_terms;
            lr_orchid_shphdr(i).fmx_load_id            := NULL;
            lr_orchid_shphdr(i).asn_type               := NULL;
            lr_orchid_shphdr(i).icc_cd1                := NULL;                             --lr_com_shphdr(i).icc_cd1;
            lr_orchid_shphdr(i).trans_type             := NULL;
            lr_orchid_shphdr(i).ref_no1                := NULL;
            lr_orchid_shphdr(i).ref_no2                := NULL;
            lr_orchid_shphdr(i).ref_no3                := NULL;
            lr_orchid_shphdr(i).ref_no4                := NULL;
            lr_orchid_shphdr(i).cre_dat                := SYSDATE;
            lr_orchid_shphdr(i).cre_usr                := USER;
            lr_orchid_shphdr(i).batch_ctrl_no          := lv_hdr_batch_ctrl_no;
            -- logic to get total boxes and weight.
            BEGIN
              SELECT SUM(no_cartons), SUM(weight)
                INTO lr_orchid_shphdr(i).total_boxes
                   , lr_orchid_shphdr(i).weight
                FROM com_plline@com_pricing.world pll
               WHERE pll.plheadno = lr_com_shphdr(i).plheadno;
            EXCEPTION
             WHEN OTHERS THEN
                lr_orchid_shphdr(i).total_boxes := NULL;
                lr_orchid_shphdr(i).weight      := NULL;
            END;
          END LOOP;
        -- initialize the variables for next loop cycle.
        cnt := 0;
        cnt1 := 0;
        -- populate the shipment header interface table.
        FOR x IN 1..lr_orchid_shphdr.COUNT
        LOOP
          ld_hdr_download_end_tstamp := lr_orchid_shphdr(x).cre_dat;
          INSERT INTO orchid_shipment_hdr_intf
                    (record_qualifier
                    ,client_id
                    ,ord_no
                    ,tracking_no
                    ,container_no
                    ,bol_no
                    ,carrier_id
                    ,plant_id
                    ,erp_ord_no
                    ,erp_ord_no2
                    ,po_no
                    ,ship_to_id
                    ,ship_to_addr_id
                    ,scac
                    ,actual_ship_date
                    ,cfm_order_type
                    ,company_code
                    ,no_of_order_lines
                    ,pick_invoice_no
                    ,total_boxes
                    ,weight
                    ,ord_date
                    ,orig_tender_date
                    ,orig_delv_date
                    ,delivery_flag
                    ,delv_date_from
                    ,delv_date_to
                    ,orig_carr_cd
                    ,routing_comment
                    ,segment_type
                    ,back_order_flag
                    ,addr_override_flag
                    ,fmx_assigned_carr
                    ,fmx_assigned_ship_date
                    ,fmx_assigned_delv_date
                    ,freight_terms
                    ,fmx_load_id
                    ,asn_type
                    ,upl_status
                    ,icc_cd1
                    ,trans_type
                    ,ref_no1
                    ,ref_no2
                    ,ref_no3
                    ,ref_no4
                    ,cre_dat
                    ,cre_usr
                    ,batch_ctrl_no)
            VALUES
                    ( 10
                    ,lr_orchid_shphdr(x).client_id
                    ,lr_orchid_shphdr(x).ord_no
                    ,lr_orchid_shphdr(x).tracking_no
                    ,lr_orchid_shphdr(x).container_no
                    ,lr_orchid_shphdr(x).bol_no
                    ,lr_orchid_shphdr(x).carrier_id
                    ,lr_orchid_shphdr(x).plant_id
                    ,lr_orchid_shphdr(x).erp_ord_no
                    ,lr_orchid_shphdr(x).erp_ord_no2
                    ,lr_orchid_shphdr(x).po_no
                    ,lr_orchid_shphdr(x).ship_to_id
                    ,lr_orchid_shphdr(x).ship_to_addr_id
                    ,lr_orchid_shphdr(x).scac
                    ,lr_orchid_shphdr(x).actual_ship_date
                    ,lr_orchid_shphdr(x).cfm_order_type
                    ,lr_orchid_shphdr(x).company_code
                    ,lr_orchid_shphdr(x).no_of_order_lines
                    ,lr_orchid_shphdr(x).pick_invoice_no
                    ,lr_orchid_shphdr(x).total_boxes
                    ,lr_orchid_shphdr(x).weight
                    ,lr_orchid_shphdr(x).ord_date
                    ,lr_orchid_shphdr(x).orig_tender_date
                    ,lr_orchid_shphdr(x).orig_delv_date
                    ,lr_orchid_shphdr(x).delivery_flag
                    ,lr_orchid_shphdr(x).delv_date_from
                    ,lr_orchid_shphdr(x).delv_date_to
                    ,lr_orchid_shphdr(x).orig_carr_cd
                    ,lr_orchid_shphdr(x).routing_comment
                    ,lr_orchid_shphdr(x).segment_type
                    ,lr_orchid_shphdr(x).back_order_flag
                    ,lr_orchid_shphdr(x).addr_override_flag
                    ,lr_orchid_shphdr(x).fmx_assigned_carr
                    ,lr_orchid_shphdr(x).fmx_assigned_ship_date
                    ,lr_orchid_shphdr(x).fmx_assigned_delv_date
                    ,lr_orchid_shphdr(x).freight_terms
                    ,lr_orchid_shphdr(x).fmx_load_id
                    ,lr_orchid_shphdr(x).asn_type
                    ,00
                    ,lr_orchid_shphdr(x).icc_cd1
                    ,lr_orchid_shphdr(x).trans_type
                    ,lr_orchid_shphdr(x).ref_no1
                    ,lr_orchid_shphdr(x).ref_no2
                    ,lr_orchid_shphdr(x).ref_no3
                    ,lr_orchid_shphdr(x).ref_no4
                    ,lr_orchid_shphdr(x).cre_dat
                    ,lr_orchid_shphdr(x).cre_usr
                    ,lr_orchid_shphdr(x).batch_ctrl_no);
        END LOOP;
        -- populate the shipment address interface table.
        FOR y IN 1..lr_orchid_shpadr.COUNT
        LOOP
          ld_adr_download_end_tstamp := lr_orchid_shpadr(y).cre_dat;
          INSERT INTO orchid_shipment_address_intf
                      ( record_qualifier
                      , client_id
                      , ord_no
                      , tracking_no
                      , addr_name
                      , attn_line
                      , addr_line1
                      , addr_line2
                      , addr_line3
                      , addr_line4
                      , addr_line5
                      , city
                      , state_cd
                      , zip
                      , zip_ext
                      , country_cd
                      , tax_geo_cd
                      , work_phone
                      , email1
                      , cre_dat
                      , cre_usr
                      , batch_ctrl_no)
               VALUES ( 14
                      , lr_orchid_shpadr(y).client_id
                      , lr_orchid_shpadr(y).ord_no
                      , lr_orchid_shpadr(y).tracking_no
                      , lr_orchid_shpadr(y).addr_name
                      , lr_orchid_shpadr(y).attn_line
                      , lr_orchid_shpadr(y).addr_line1
                      , lr_orchid_shpadr(y).addr_line2
                      , lr_orchid_shpadr(y).addr_line3
                      , lr_orchid_shpadr(y).addr_line4
                      , lr_orchid_shpadr(y).addr_line5
                      , lr_orchid_shpadr(y).city
                      , lr_orchid_shpadr(y).state_cd
                      , lr_orchid_shpadr(y).zip
                      , lr_orchid_shpadr(y).zip_ext
                      , lr_orchid_shpadr(y).country_cd
                      , lr_orchid_shpadr(y).tax_geo_cd
                      , lr_orchid_shpadr(y).work_phone
                      , lr_orchid_shpadr(y).email1
                      , lr_orchid_shpadr(y).cre_dat
                      , lr_orchid_shpadr(y).cre_usr
                      , lr_orchid_shpadr(y).batch_ctrl_no);
        END LOOP;
        -- populate the shipment detail interface table.
        FOR z IN 1..lr_orchid_shpdtl.COUNT
        LOOP
          ld_dtl_download_end_tstamp := lr_orchid_shpdtl(z).cre_dat;
          INSERT INTO orchid_shipment_dtl_intf
                      ( record_qualifier
                      , client_id
                      , ord_no
                      , ord_line_no
                      , erp_line_no
                      , sku
                      , tracking_no
                      , container_no
                      , ord_qty
                      , ship_qty
                      , price_point
                      , pick_invoice_no
                      , cancel_qty
                      , bldg_id
                      , sku_company
                      , sku_desc
                      , icc_cd1
                      , erp_ord_no
                      , cre_dat
                      , cre_usr
                      , batch_ctrl_no)
               VALUES ( 20
                      , lr_orchid_shpdtl(z).client_id
                      , lr_orchid_shpdtl(z).ord_no
                      , lr_orchid_shpdtl(z).ord_line_no
                      , lr_orchid_shpdtl(z).erp_line_no
                      , lr_orchid_shpdtl(z).sku
                      , lr_orchid_shpdtl(z).tracking_no
                      , lr_orchid_shpdtl(z).container_no
                      , lr_orchid_shpdtl(z).ord_qty
                      , lr_orchid_shpdtl(z).ship_qty
                      , lr_orchid_shpdtl(z).price_point
                      , lr_orchid_shpdtl(z).pick_invoice_no
                      , lr_orchid_shpdtl(z).cancel_qty
                      , lr_orchid_shpdtl(z).bldg_id
                      , lr_orchid_shpdtl(z).sku_company
                      , lr_orchid_shpdtl(z).sku_desc
                      , lr_orchid_shpdtl(z).icc_cd1
                      , lr_orchid_shpdtl(z).erp_ord_no
                      , lr_orchid_shpdtl(z).cre_dat
                      , lr_orchid_shpdtl(z).cre_usr
                      , lr_orchid_shpdtl(z).batch_ctrl_no);
        END LOOP;
        COMMIT;
      END LOOP;
      CLOSE c_com_shphdr;
      -- set the status to success
      UPDATE comoes.download_batch_info
         SET batch_ctrl_no = orchid_plhead_btch_ctrl_seq.NEXTVAL
           , dwn_status = '90'
           , download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
       WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
         AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
      UPDATE comoes.download_batch_info
         SET batch_ctrl_no = orchid_address_btch_ctrl_seq.NEXTVAL
           , dwn_status = '90'
           , download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
       WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
         AND batch_ctrl_no = lv_adr_batch_ctrl_no;
      UPDATE comoes.download_batch_info
         SET batch_ctrl_no = orchid_plline_btch_ctrl_seq.NEXTVAL
           , dwn_status = '90'
           , download_end_tstamp = NVL(ld_dtl_download_end_tstamp,SYSDATE)
       WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
         AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
      -- Update the download status to success in the interface table.
      -- Shipment Header
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
        -- load is not sucess then set the status to fail
        UPDATE comoes.download_batch_info
           SET dwn_status = '99'
         WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
           AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
        UPDATE comoes.download_batch_info
           SET dwn_status = '99'
         WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
           AND batch_ctrl_no = lv_adr_batch_ctrl_no;
        UPDATE comoes.download_batch_info
           SET dwn_status = '99'
         WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
           AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
        COMMIT;
        DBMS_OUTPUT.PUT_LINE('Following error occured while executing ORCHID_SHIPMENT_INTF procedure...!!!'||SQLERRM);
        RAISE;
    END orchid_shipment_interface;Edited by: BluShadow on 03-Aug-2011 13:28
    added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &nb

    Please read the Forum FAQ on how to ask a question, particularly how to format code
    SQL and PL/SQL FAQ
    SQL and PL/SQL FAQ
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
    RAISE;http://tkyte.blogspot.com/2008/01/why-do-people-do-this.html

  • For loop issue and error exception

    I am finishing up a program and having a few issues....I can send my instructions so it may seem easier to what I want...the first issue deals with the for loop for the 2nd for loop in the actionperformed when i click on go it does not change any of the boxes to yellow
    Also when I check for errors it does not check with the code I have...I know it says on the instructions to use try\catch but I am just going to use if statements because I am not very familar with the try\catch and will accept some points takin off...any help with this by tonight id really appreciate it as long as noone is too busy...Thanks
    instructions:
    This will incorporate arrays, for loops, and Frames all in one.
    Create a panel containing an array of 16 TextArea components that change color to correspond with the start, stop, and step values entered by the user. Perform the following tasks to create the Checkerboard Array application shown below. When the user enters the start, stop, and step fields and then clicks the Go button, the results are also shown below.
    1.     Call your application Checkerboard.java
    2.     You will need the following variables� declare them as private:
    a.     16 component TextArea array
    b.     a Panel to hold the array
    c.     3 TextField components with length of 10
    d.     3 int variables to receive the start, stop, and step values
    e.     3 Labels to display the words Start, Stop, and Step
    f.     a Go button
    g.     a Clear button
    h.     a Panel to hold the 3 TextFields, 3 Labels, and the 2 Buttons
    3.     Create a constructor method to:
    a.     construct each of the components declared above and initializes the start, stop, and step variables to zero (when constructing the TextArea components, use the following parameters: null, 3, 5, 3)
    b.     set the Frame layout to BorderLayout
    c.     write a for loop to loop the array and set each of the 16 TextArea components in that array so they cannot be edited. In the same loop, set each of the TextArea components text to be 1 more than the index number. Also in this same loop, set the background of each of the TextArea components to white.
    d.     set the Panel for the TextArea components to GridLayout with 4 rows, 4 columns, and both gaps set to 10
    e.     set the Panel for the TextFields, Labels, and button to GridLayout with 3 rows, 3 columns, and both gaps set to 5
    f.     add the components to their respective Panels
    g.     make the buttons clickable
    h.     place the Panels in the Frame� put one in the NORTH and one in the CENTER
    i.     Enter the addWindowListener() method described in the chapter� this is the method that overrides the click of the X so it terminates the application
    4.     In your actionPerformed() method:
    a.     convert the data in your TextFields to int and store them in the variables declared above
    b.     write a loop that goes through the array setting every background color to blue
    c.     write another loop that�s based on the user inputs. Each time the loop is executed, change the background color to yellow (so� start your loop at the user�s specified starting condition. You�ll stop at the user�s specified stopping value. You�ll change the fields to yellow every time you increment your loop based on the step value. REMEMBER: Your displayed values are 1 off from your index numbers!!)
    5.     Write a main() method that creates an instance of the Checkerboard Frame.
    a.     set the bounds for the frame to 50, 100, 300, 400
    b.     set the title bar caption to Checkerboard Array
    c.     use the setVisible() method to display the application Frame during execution
    6.     After you get all of this complete, include error handling to make sure:
    a.     the values entered in the TextFields are valid integers
    b.     the start value is greater than or equal to 1 and less than or equal to 16
    c.     the stop value is greater than or equal to 1 and less than or equal to 16
    d.     the step value is greater than or equal to 1 and less than or equal to 16
    e.     the start condition is less than the stop condition
    f.     when an error occurs, give an error message in a dialog box that is specific to their error, remove the text from the invalid field, and put the cursor in that field so the user has a chance to re-enter� this can be accomplished by using multiple try/catch statements
    g.     only change the colors if the numbers are valid
    7.     Create a clear button as seen in the example below. This button should:
    a.     clear out all 3 TextFields
    b.     change the background color of all TextArea array elements to white
    c.     put the cursor in the start field
    8.     Document!!
    my code is:
    //packages to import
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class Checkerboard extends Frame implements ActionListener
         private Panel topPanel;
         private TextArea topDisplay[];
         private Panel bottomPanel;
         private TextField startField = new TextField(10);
         private TextField stopField = new TextField(10);
         private TextField stepField = new TextField(10);
         private Label startLabel = new Label ("Start");
         private Label stopLabel = new Label ("Stop");
         private Label stepLabel = new Label ("Step");
         private Button goButton;
         private Button clearButton;
         private boolean clearText;
         private boolean first;
         private int start;
         private int stop;
         private int step;
         //constructor methods
         public Checkerboard()
              //construct components and initialize beginning values
              topPanel = new Panel();
              topDisplay = new TextArea[16];
              goButton = new Button("Go");
              clearButton = new Button("Clear");
              first = true;
              bottomPanel = new Panel();
              int start = 0;
              int stop = 0;
              int step = 0;
              bottomPanel.add(startField);
              bottomPanel.add(stopField);
              bottomPanel.add(stepField);
              bottomPanel.add(startLabel);
              bottomPanel.add(stopLabel);
              bottomPanel.add(stepLabel);
              bottomPanel.add(goButton);
              goButton.addActionListener(this);
              bottomPanel.add(clearButton);
              clearButton.addActionListener(this);
              clearText = true;
              //set layouts for the Frame and Panels
              setLayout(new BorderLayout());
              topPanel.setLayout(new GridLayout(4, 4, 10, 10));
              bottomPanel.setLayout(new GridLayout(3, 3, 5, 5));
              //construct the Display
              for(int i = 0; i <= 15; i++)
                        topDisplay[i] = new TextArea(null, 3, 5, 3);
                        topDisplay.setText(String.valueOf(i+1));
                        topDisplay[i].setEditable(false);
                        topPanel.add(topDisplay[i]);
              //add components to frame
              add(topPanel, BorderLayout.NORTH);
              add(bottomPanel, BorderLayout.CENTER);
              //allow the x to close the application
              addWindowListener(new WindowAdapter()
                        public void windowClosing(WindowEvent e)
                                  System.exit(0);
                   } //end window adapter
         public static void main(String args[])
              Checkerboard f = new Checkerboard();
              f.setTitle("Checkerboard Array");
              f.setBounds(50, 100, 300, 400);
              f.setLocationRelativeTo(null);
              f.setVisible(true);
         } //end main
         public void actionPerformed(ActionEvent e)
              //test go
              String arg = e.getActionCommand();
              //go button was clicked
              if(arg.equals("Go"))
                   //convert data in TextField to int
                   int start = Integer.parseInt(startField.getText());
                   int stop = Integer.parseInt(stopField.getText());
                   int step = Integer.parseInt(stepField.getText());
                   if((start <= 1) && (start > 16))
                        JOptionPane.showMessageDialog(null, "You must enter start between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                        startField.setText(" ");
                        startField.requestFocus();
                   if ((stop < 1) && (stop > 16))
                        JOptionPane.showMessageDialog(null, "You must enter stop between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                        stopField.setText(" ");
                        stopField.requestFocus();
                   if ((step < 1) && (step > 16))
                        JOptionPane.showMessageDialog(null, "You must enter step between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                        stepField.setText(" ");
                        stepField.requestFocus();
                   if (start < stop)
                        JOptionPane.showMessageDialog(null, "Stop cannot be larger than start", "Error", JOptionPane.ERROR_MESSAGE);
                        startField.setText(" ");
                        stopField.setText(" ");
                        stepField.setText(" ");
                        startField.requestFocus();
                   for(int i = 0; i <=16; i++)
                   topDisplay[i].setBackground(Color.blue);
                   for(int i = start; i <= stop; step++)
                   topDisplay[i].setBackground(Color.yellow);
              } //end the if go
              //clear button was clicked
              if(arg.equals("Clear"))
                   clearText = true;
                   startField.setText("");
                   stopField.setText("");
                   stepField.setText("");
                   first = true;
                   setBackground(Color.white);
                   startField.requestFocus();
              } //end the if clear
         }//end action listener
    }//end class

    got the yellow boxes to come up but just one box.....so is there something wrong with my yellow set background because I am not seeing any more errors
    //packages to import
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class Checkerboard extends Frame implements ActionListener
         private Panel topPanel;
         private TextArea topDisplay[];
         private Panel bottomPanel;
         private TextField startField = new TextField(10);
         private TextField stopField = new TextField(10);
         private TextField stepField = new TextField(10);
         private Label startLabel = new Label ("Start");
         private Label stopLabel = new Label ("Stop");
         private Label stepLabel = new Label ("Step");
         private Button goButton;
         private Button clearButton;
         private boolean clearText;
         private boolean first;
         private int start;
         private int stop;
         private int step;
         //constructor methods
         public Checkerboard()
              //construct components and initialize beginning values
              topPanel = new Panel();
              topDisplay = new TextArea[16];
              goButton = new Button("Go");
              clearButton = new Button("Clear");
              first = true;
              bottomPanel = new Panel();
              int start = 0;
              int stop = 0;
              int step = 0;
              bottomPanel.add(startField);
              bottomPanel.add(stopField);
              bottomPanel.add(stepField);
              bottomPanel.add(startLabel);
              bottomPanel.add(stopLabel);
              bottomPanel.add(stepLabel);
              bottomPanel.add(goButton);
              goButton.addActionListener(this);
              bottomPanel.add(clearButton);
              clearButton.addActionListener(this);
              clearText = true;
              //set layouts for the Frame and Panels
              setLayout(new BorderLayout());
              topPanel.setLayout(new GridLayout(4, 4, 10, 10));
              bottomPanel.setLayout(new GridLayout(3, 3, 5, 5));
              //construct the Display
              for(int i = 0; i <= 15; i++)
                        topDisplay[i] = new TextArea(null, 3, 5, 3);
                        topDisplay.setText(String.valueOf(i+1));
                        topDisplay[i].setEditable(false);
                        topPanel.add(topDisplay[i]);
              //add components to frame
              add(topPanel, BorderLayout.NORTH);
              add(bottomPanel, BorderLayout.CENTER);
              //allow the x to close the application
              addWindowListener(new WindowAdapter()
                        public void windowClosing(WindowEvent e)
                                  System.exit(0);
                   } //end window adapter
              public static void main(String args[])
                        Checkerboard f = new Checkerboard();
                        f.setTitle("Checkerboard Array");
                        f.setBounds(50, 100, 300, 400);
                        f.setLocationRelativeTo(null);
                        f.setVisible(true);
                   } //end main
                   public void actionPerformed(ActionEvent e)
                        boolean done = false;
                        //test go
                        String arg = e.getActionCommand();
                        //go button was clicked
                        if(arg.equals("Go"))
                   //convert data in TextField to int
                   int start = Integer.parseInt(startField.getText());
                   int stop = Integer.parseInt(stopField.getText());
                   int step = Integer.parseInt(stepField.getText());
                   while(!done)
                        try
                             if((start <= 1) && (start > 16)) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "You must enter start between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                             startField.setText(" ");
                             startField.requestFocus();
                        } //end catch
                        try
                             if ((stop < 1) && (stop > 16)) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "You must enter stop between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                             stopField.setText(" ");
                             stopField.requestFocus();
                        } //end catch
                        try
                             if ((step < 1) && (step > 16)) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "You must enter step between 1 and 16", "Error", JOptionPane.ERROR_MESSAGE);
                             stepField.setText(" ");
                             stepField.requestFocus();
                        } //end catch
                        try
                             if (start > stop) throw new NumberFormatException();
                             else done = true;
                        } //end try
                        catch (NumberFormatException f)
                             JOptionPane.showMessageDialog(null, "Stop cannot be larger than start", "Error", JOptionPane.ERROR_MESSAGE);
                             startField.setText(" ");
                             stopField.setText(" ");
                             stepField.setText(" ");
                             startField.requestFocus();
                        } //end catch
              } //end while
                        for(int i = 0; i <=15; i++)
                        topDisplay[i].setBackground(Color.blue);
                        for(int i = start; i <= stop; step++)
                        topDisplay[i].setBackground(Color.yellow);
                   } //end the if go
                   //clear button was clicked
                   if(arg.equals("Clear"))
                        clearText = true;
                        startField.setText("");
                        stopField.setText("");
                        stepField.setText("");
                        first = true;
                        setBackground(Color.white);
                        startField.requestFocus();
                   } //end the if clear
         }//end action listener
    }//end class

  • How to use the select statement in for loop

    Hi All,
    my question is can we use select statement in for loop like as follows .
    for key in select key from one_table.
    when i am using this am getting an error like Found select invalid i identifier
    how to make use of select statement in for loop
    please suggest me .
    Thanks
    Sree

    SQL>set serveroutput on;
    SQL> DECLARE
         BEGIN
         FOR Cur_Rec IN (SELECT dname FROM dept) LOOP
          DBMS_OUTPUT.PUT_LINE(Cur_Rec.dname);
         END LOOP;
         END;
    SQL>
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONSAs per your requirement always filter the Query beforehand
    Like
    FOR Cur_Rec IN (SELECT key FROM <table> WHERE key=1) LOOP
    END LOOP;Edited by: Lokanath Giri on १ दिसंबर, २०११ ३:५६ अपराह्न

  • Need help with a For loop that uses a Break statement

    I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
    public class Break
    public static void main ( String args []) (;
         int total = 0
         int counter = 0
         for { (int number = 100; total >=50; total --)
         if (counter == 0)
         break;
         } // end of for loop
         int output = number/counter
         system.out.printf("The number is" %d output/n)
         }// end of method main
    }// end of class Break

    Im sorry I didnt explain myself very well i do not need the break statement at all.
    I now have this code:
    public class BreakTest
       public static void main( String args[] )
          int count; // control variable also used after loop terminates
         for (int i = 100; i >= 50; i = ++count)
       if (i >= 50) {
        continue;
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
       } // end main
    } // end class BreakTest
    /code]
    and i get these error messages:
    F:\csc148>javac BreakTest.java
    BreakTest.java:9: variable count might not have been initialized
         for (int i = 100; i >= 50; i = ++count)
                                          ^
    BreakTest.java:15: variable count might not have been initialized
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
                                                                    ^
    2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Error -200429 DAQmx read (counter u32 1ch 1samp).vi -append- Edge count in for loop

    I am receiving error -200429 DAQmx read (counter u32 1ch 1 samp).vi <append>. This is occuring on the second loop of a for loop.
    I have a sequence inside the for loop that is using four DAQmx assistant vi's for edge count at various times in the sequence. All four of these count fine the first time through but at the beginning of the second loop the first edge count receives this error and does not count.
    Any ideas?

    The code you have supplied is similar to the converted subvi but this code will give an empty task error on the DAQmx Create Channel vi.
    Notice on the Daqmx create task vi that there is nothing wired to the "Task to copy" or the "Global virtual channels" connectors - I believe this is why the task is empty when sent to the Daqmx create channel vi.
    The code we are currently using is a modification of a previous code used before a recent upgrade. It may be better in your/NI eyes to re-write this into a State machine but time constraints and resources do not allow that at this time - All other parts of the current program work except for the counter on the second iteration. Would rather not reinvent the wheel at this point. 
    If the task is being cleared was the issue then the other three should also not execute. The issue appears to be the "First Call"
    I have attached a zip file of the complete program as it is now written to give you a better idea of the whole picture.
    Attachments:
    Test Machine current code.zip ‏657 KB

  • Using CONTINUE-WHEN statement in FOR loop

    I'm trying to use CONTINUE-WHEN statement inside of a FOR loop. For example;
    FOR cnt IN 1 .. securityTable.COUNT LOOP
    CONTINUE WHEN cnt = 3;
    --do the job here...
    END LOOP;
    ... but it's not working. It gives me this error;
    "PLS-00103: Encountered the symbol "WHEN" when expecting one of the following:
    := . ( @ % ;"
    What can be the problem?

    In the first link there was "CONTINUE WHEN inside of the inner for loop" link and the reference gives this example
    <<outer_loop>>
    FOR i IN 1..10 LOOP
    -- Process data here
    FOR j IN 1..10 LOOP
    FETCH c1 INTO v_employees;
    CONTINUE outer_loop WHEN c1%NOTFOUND;
    -- Process data here
    END LOOP;
    END LOOP outer_loop;
    well; I'm not trying to "continue" the outer loop: I just want to "continue" the loop where CONTINUE-WHEN statement belongs to.
    I'm using Oracle 10g.

Maybe you are looking for

  • How to see Trial Balance for a Segment

    Hi Experts, Does anybody has idea on how to see Triala Balance for a Segment ? In Standard Reports for Balance Sheet and Profit & Loss, SAP B1 has provided option for filtering on Segment, but the same is not true for Trial Balance. BR Samir Gandhi

  • Flash doesn't work on IE 7

    When I go to http://www.macromedia.com/software/flash/about/ it says I have version 9,0,47,0 installed. Whenever I go to a site that uses Flash it says it's not installed. For instance, http://www.nmai.si.edu/education/codetalkers/ returns: "Native W

  • Firefox start with two pages. One says welcome to Firefox etc. And the other is my homepage (google). I want to stop the first page. How can I do this??

    Firofx (5.0) starts with two pages. One is the welcome to Firofox and also that there are Add-ons available. The other one is my homepage (google). I want to stop the first page. How can I do this?

  • Playing Chess on Snow Leopard

    I'm playing a game of chess, the application that comes with SL, and it is taking 99% of the CPU and fans are 6000+ RPMs. Why is this? Very strange, never happened before. Thanks.

  • Break point in a program

    i kept a break point in a user exit with the statement BREAK-POINT. but the control is not stopping there , i am not testing it so didnt give it as user specific . what might be the mistake ? is it not the proper user exit , i have created a project