How to use Declare Cursor

Hello I ran into a problem while running a SQL command using OracleCommand. I am Declaring a cursor to retrieve values from table A and then loop through that dataset to update table B. When I run this script I see my application hanging right there without any response. Do I have to use REF CURSOR? HOW to use it? I can't use DECLARE CURSOR? Need help. Here is my present SQL command
DECLARE CURSOR c_load IS SELECT VALUATION_YR_MTH_NBR,PMT_PRD_NBR,PMT_DAY,PMT_MTH,PMT_YR,SERIES_NAME,GROUP_NAME,FNC_PROD_NAME,SCENARIO_ABBR,PRIN_SCHED_BAL,NET_INT_AMT,SCHED_PRIN_AMT,SPEED_PREPMT_1_MTH_AMT,LOSS_TOTAL_AMT,SURETY_FEE_AMT,INT_FROM_OTHER_GROUP_AMT,PRIN_FROM_OTHER_GROUP_AMT,SENIOR_FIXED_RATE_BOND_BAL,SENIOR_FLOAT_RATE_BOND_BAL,SUBORDINATE_RATE_BOND_BAL,IO_NOTIONAL_BAL,NON_IO_FIXED_INT_PAID_AMT,NON_IO_FLOAT_INT_PAID_AMT,IO_INT_PAID_AMT,TOTAL_PRIN_AMT,BOND_WRITE_DOWNS_AMT,SURETY_PMTS_AMT,OC_BAL,OC_TARGET_BAL,RESIDUAL_INT_AMT,RESIDUAL_PRIN_AMT,RESIDUAL_TOTAL_AMT, CHG_LST_DATE, CHG_LST_USER_ID, CHG_LST_PROG_NAME FROM RESIDCF.CASH_FLOW_FORECAST_UPLOAD WHERE PREV_UPLOADED_IND='Y'; BEGIN FOR c_inx IN c_load LOOP UPDATE RESIDCF.CASH_FLOW_FORECAST SET PMT_DAY=c_inx.PMT_DAY,PMT_MTH=c_inx.PMT_MTH,PMT_YR=c_inx.PMT_YR,PRIN_SCHED_BAL=c_inx.PRIN_SCHED_BAL,NET_INT_AMT=c_inx.NET_INT_AMT,SCHED_PRIN_AMT=c_inx.SCHED_PRIN_AMT,SPEED_PREPMT_1_MTH_AMT=c_inx.SPEED_PREPMT_1_MTH_AMT,LOSS_TOTAL_AMT=c_inx.LOSS_TOTAL_AMT,SURETY_FEE_AMT=c_inx.SURETY_FEE_AMT,INT_FROM_OTHER_GROUP_AMT=c_inx.INT_FROM_OTHER_GROUP_AMT,PRIN_FROM_OTHER_GROUP_AMT=c_inx.PRIN_FROM_OTHER_GROUP_AMT,SENIOR_FIXED_RATE_BOND_BAL=c_inx.SENIOR_FIXED_RATE_BOND_BAL,SENIOR_FLOAT_RATE_BOND_BAL=c_inx.SENIOR_FLOAT_RATE_BOND_BAL,SUBORDINATE_RATE_BOND_BAL=c_inx.SUBORDINATE_RATE_BOND_BAL,IO_NOTIONAL_BAL=c_inx.IO_NOTIONAL_BAL,NON_IO_FIXED_INT_PAID_AMT=c_inx.NON_IO_FIXED_INT_PAID_AMT,NON_IO_FLOAT_INT_PAID_AMT=c_inx.NON_IO_FLOAT_INT_PAID_AMT,IO_INT_PAID_AMT=c_inx.IO_INT_PAID_AMT,TOTAL_PRIN_AMT=c_inx.TOTAL_PRIN_AMT,BOND_WRITE_DOWNS_AMT=c_inx.BOND_WRITE_DOWNS_AMT,SURETY_PMTS_AMT=c_inx.SURETY_PMTS_AMT,OC_BAL=c_inx.OC_BAL,OC_TARGET_BAL=c_inx.OC_TARGET_BAL,RESIDUAL_INT_AMT=c_inx.RESIDUAL_INT_AMT,RESIDUAL_PRIN_AMT=c_inx.RESIDUAL_PRIN_AMT,RESIDUAL_TOTAL_AMT=c_inx.RESIDUAL_TOTAL_AMT , CHG_LST_DATE=c_inx.CHG_LST_DATE , CHG_LST_USER_ID=c_inx.CHG_LST_USER_ID , CHG_LST_PROG_NAME=c_inx.CHG_LST_PROG_NAME WHERE VALUATION_YR_MTH_NBR=c_inx.VALUATION_YR_MTH_NBR AND PMT_PRD_NBR=c_inx.PMT_PRD_NBR AND SERIES_NAME=c_inx.SERIES_NAME AND GROUP_NAME=c_inx.GROUP_NAME AND FNC_PROD_NAME=c_inx.FNC_PROD_NAME AND SCENARIO_ABBR=c_inx.SCENARIO_ABBR; END LOOP; END;

That block should run the same from ODP.NET as from SQLPlus. Which is very slowly. You shouldn't be using a cursor here. Instead try an updatable join, or better MERGE (for 9i).
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems30.htm#37586
David

Similar Messages

  • How to use parrallel cursor in this code

    hi can anyone expalin me how to use parallel cursor for this code ... 
    loop at itabkpf.
          read table ibsegpar_fu with key
                     belnr = itabkpf-belnr
                     gjahr = itabkpf-gjahr
                     bschl = '25' .
    Start insert by Pradeep 20082008
          sort: itabkpf by belnr,
                itabsegpar by belnr.
    End insert by Pradeep 20082008
          if sy-subrc = 0. "Deleted by pradeep 20082008
            select bukrs belnr gjahr bschl koart lifnr wrbtr
                   wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
                   into corresponding
                   fields of table ibsegpar_fu_1 from bseg
                   where bukrs = itabkpf-bukrs and
                   belnr = itabkpf-belnr and
                   gjahr = itabkpf-gjahr and
                   augbl <> itabkpf-belnr and
                   rebzg <> space and
                   bschl = '25'.
            loop at ibsegpar_fu_1.
    Start insert by Pradeep 20082008
              sort ibsegpar_fu_1 by belnr.
    End insert by Pradeep 20082008
              move-corresponding ibsegpar_fu_1 to itabseg.
              move ibsegpar_fu_1-belnr to itabseg-augbl.
              move ibsegpar_fu_1-rebzg to itabseg-belnr.
              move ibsegpar_fu_1-rebzj to itabseg-gjahr.
    *********to include code to pick the description for partical payment
              select single * from bseg where
                  bukrs = ibsegpar_fu_1-bukrs and
                  belnr = ibsegpar_fu_1-belnr and
                  gjahr = ibsegpar_fu_1-gjahr and
                  augbl <> ibsegpar_fu_1-belnr and
                  rebzg = space and
                  bschl <> '25'.
              move bseg-sgtxt to itabseg-sgtxt.
              clear bseg.
    *********end of code
              itabseg-wrbtr = itabseg-wrbtr * -1.
              itabseg-pswbt = itabseg-pswbt * -1.
              select single budat into lsdat from
                   bkpf where bukrs = ibsegpar_fu_1-bukrs and
                   belnr = ibsegpar_fu_1-rebzg and
                   gjahr = ibsegpar_fu_1-rebzj.
              if sy-subrc = 0.
                move lsdat to itabseg-zfbdt.
              endif.
              append itabseg.
            endloop.
          endif. "Deleted by Pradeep 20082008
        endloop.
        loop at ibsegpar_fu.
          sort ibsegpar_fu by belnr. " insert by pradeep
          move-corresponding ibsegpar_fu to itabseg.
          select bukrs belnr gjahr bschl koart lifnr wrbtr
                 rebzg rebzj sgtxt into corresponding
                 fields of table ibsegpar_fu_1 from bseg
                 where  bukrs = ibsegpar_fu-bukrs and
                 gjahr = ibsegpar_fu-gjahr and
                 augbl = ibsegpar_fu-belnr and  " Pradeep 20082008 Delete
                augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
                 rebzg = space and
                 bschl = '25'.
          if sy-subrc = 0.
            loop at ibsegpar_fu_1.
              move ibsegpar_fu_1-rebzg to itabseg-rebzg.
              move ibsegpar_fu_1-rebzj to itabseg-rebzj.
            endloop.
            move ibsegpar_fu-belnr to itabseg-augbl.
            move itabseg-rebzg to itabseg-belnr.
            move itabseg-rebzj to itabseg-gjahr.
            itabseg-wrbtr = itabseg-wrbtr * -1.
            itabseg-pswbt = itabseg-pswbt * -1.
            select single budat into lsdat from
                 bkpf where bukrs = ibsegpar_fu-bukrs and
                 belnr = itabseg-rebzj and
                 gjahr = itabseg-rebzj.
            if sy-subrc = 0.
              move lsdat to itabseg-zfbdt.
            endif.
            append itabseg.
            read table itabseg with key
                 belnr = itabseg-rebzg
                 gjahr = itabseg-rebzj
                 bschl = '31' .
            if sy-subrc = 0.
             delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
            endif.
          endif.
        endloop.
    Start insert by Pradeep 20082008
         loop at itabseg.
          if itabseg-belnr = itabseg-augbl.
            delete itabseg.
          elseif itabseg-belnr = ' '.
            delete itabseg.
          endif.
        endloop.
    End insert by Pradeep 20082008

    hi can anyone expalin me how to use parallel cursor for this code ... 
    loop at itabkpf.
          read table ibsegpar_fu with key
                     belnr = itabkpf-belnr
                     gjahr = itabkpf-gjahr
                     bschl = '25' .
    Start insert by Pradeep 20082008
          sort: itabkpf by belnr,
                itabsegpar by belnr.
    End insert by Pradeep 20082008
          if sy-subrc = 0. "Deleted by pradeep 20082008
            select bukrs belnr gjahr bschl koart lifnr wrbtr
                   wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
                   into corresponding
                   fields of table ibsegpar_fu_1 from bseg
                   where bukrs = itabkpf-bukrs and
                   belnr = itabkpf-belnr and
                   gjahr = itabkpf-gjahr and
                   augbl <> itabkpf-belnr and
                   rebzg <> space and
                   bschl = '25'.
            loop at ibsegpar_fu_1.
    Start insert by Pradeep 20082008
              sort ibsegpar_fu_1 by belnr.
    End insert by Pradeep 20082008
              move-corresponding ibsegpar_fu_1 to itabseg.
              move ibsegpar_fu_1-belnr to itabseg-augbl.
              move ibsegpar_fu_1-rebzg to itabseg-belnr.
              move ibsegpar_fu_1-rebzj to itabseg-gjahr.
    *********to include code to pick the description for partical payment
              select single * from bseg where
                  bukrs = ibsegpar_fu_1-bukrs and
                  belnr = ibsegpar_fu_1-belnr and
                  gjahr = ibsegpar_fu_1-gjahr and
                  augbl <> ibsegpar_fu_1-belnr and
                  rebzg = space and
                  bschl <> '25'.
              move bseg-sgtxt to itabseg-sgtxt.
              clear bseg.
    *********end of code
              itabseg-wrbtr = itabseg-wrbtr * -1.
              itabseg-pswbt = itabseg-pswbt * -1.
              select single budat into lsdat from
                   bkpf where bukrs = ibsegpar_fu_1-bukrs and
                   belnr = ibsegpar_fu_1-rebzg and
                   gjahr = ibsegpar_fu_1-rebzj.
              if sy-subrc = 0.
                move lsdat to itabseg-zfbdt.
              endif.
              append itabseg.
            endloop.
          endif. "Deleted by Pradeep 20082008
        endloop.
        loop at ibsegpar_fu.
          sort ibsegpar_fu by belnr. " insert by pradeep
          move-corresponding ibsegpar_fu to itabseg.
          select bukrs belnr gjahr bschl koart lifnr wrbtr
                 rebzg rebzj sgtxt into corresponding
                 fields of table ibsegpar_fu_1 from bseg
                 where  bukrs = ibsegpar_fu-bukrs and
                 gjahr = ibsegpar_fu-gjahr and
                 augbl = ibsegpar_fu-belnr and  " Pradeep 20082008 Delete
                augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
                 rebzg = space and
                 bschl = '25'.
          if sy-subrc = 0.
            loop at ibsegpar_fu_1.
              move ibsegpar_fu_1-rebzg to itabseg-rebzg.
              move ibsegpar_fu_1-rebzj to itabseg-rebzj.
            endloop.
            move ibsegpar_fu-belnr to itabseg-augbl.
            move itabseg-rebzg to itabseg-belnr.
            move itabseg-rebzj to itabseg-gjahr.
            itabseg-wrbtr = itabseg-wrbtr * -1.
            itabseg-pswbt = itabseg-pswbt * -1.
            select single budat into lsdat from
                 bkpf where bukrs = ibsegpar_fu-bukrs and
                 belnr = itabseg-rebzj and
                 gjahr = itabseg-rebzj.
            if sy-subrc = 0.
              move lsdat to itabseg-zfbdt.
            endif.
            append itabseg.
            read table itabseg with key
                 belnr = itabseg-rebzg
                 gjahr = itabseg-rebzj
                 bschl = '31' .
            if sy-subrc = 0.
             delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
            endif.
          endif.
        endloop.
    Start insert by Pradeep 20082008
         loop at itabseg.
          if itabseg-belnr = itabseg-augbl.
            delete itabseg.
          elseif itabseg-belnr = ' '.
            delete itabseg.
          endif.
        endloop.
    End insert by Pradeep 20082008

  • How to use open cursor and iner join in one statement

    Hello All,
    Could any one post the code for the below question?
    How to use open cursor and iner join in one statement
    Regards,
    Lisa

    OPEN CURSOR c FOR SELECT     carrid connid fldate bookid smoker
                        FROM     sbook innerjoin shook
                        ORDER BY carrid connid fldate smoker bookid.
    Pls reward if helpful.

  • How to use this cursor?

    I have this sql statement as part of my pl/sql code:
    SELECT DATE, PRICE
    FROM TABLE T
    WHERE T.A1 = V1
    AND T.A2 = V2
    AND T.A3 = V3
    However, I don't know how many A's and corresponding V's in the statement when coding.
    So I declare a cursor on TABLE. The question is how I can use this cursor for the statement?

    declare cursor C
    (in_a1 table_t.a1%type
    ,in_a2 table_t.a2%type
    ,in_a3 table_t.a3%type
    is
    SELECT DATE, PRICE
    FROM TABLE T
    WHERE T.A1 = in_a1
    AND T.A2 = in_a2
    AND T.A3 = in_a3
    using as follows
    begin
    open C(V1,V2,V3);
    fetch C into .....
    or
    begin
    for p in C(V1,V2,V3) loop
    Can also
    procedure xxx(V1,V2....) is
    cursor C is
    SELECT DATE, PRICE
    FROM TABLE T
    WHERE T.A1 = V1
    AND T.A2 = V2
    AND T.A3 = V3
    begin
    open C;
    fetch C into...

  • How to use SET CURSOR in REUSE_ALV_HIERSEQ_LIST_DISPLAY

    Hi,
    I have added new fields in Standard VL10C ALV report , I have added one editable field in this standard ALV output.
    I want to set the cursor by default on the editable column on the specific row depending on some condition also if possible
    i want to highlight only that particular row.
    Please reply if anybody knows how to do this.
    Thanks,
    Pawan

    Hİ Pawan
    You can see the list of events supported by reusable alv with function REUSE_ALV_EVENTS_GET
    when I run this function in se37 I see the some events maybe helpful for your question
    PF_STATUS_SET : this has to be called from PBO of your screen, so you can try to use SET CURSOR
    command to put cursor on the selected field
    BEFORE_LINE_OUTPUT : It's called before the output of every single line so you should use command
    "FORMAT COLOR COL_POSITIVE INTENSIFIED ON.  "for highlighting the line
    AFTER_LINE_OUTPUT : than u can use "FORMAT COLOR COL_POSITIVE INTENSIFIED OFF." command
    I hope it'll be helpful.

  • How to use at cursor selection

    hi gurus,
             can anyone tell wats the purpose of
    'At cursor-selection' and how to use it in pai module?????
    regards,
    balaji.s

    hi balaji,
    The Best explanation with example comes from our help.sap.com....
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabbd35c111d1829f0000e829fbfe/content.htm
    Also this might help...
    MODULE mod CURSOR-SELECTION}
    CHAIN-REQUEST}
    SWITCH switch .
    ... AT CURSOR-SELECTION
    The AT CURSOR-SELECTION addition at the event PAI causes the module mod to be called only if
    The function used to trigger event PAI has function code "CS" and function type "S"
    The cursor is placed on a single input or output field of the screen at the moment of the user action
    The call occurs within the usual PAI processing, meaning that the automatic input checks defined in the system or in the ABAP Dictionary are executed and the MODULE statement is called according to its position in the event block. You can use the addition in connection with the FIELD statement.
    If the PAI event is triggered under the above circumstances, the function code is not passed to sy-ucomm and the OK field. They keep their previous values.
    Note
    The function type and function code of a function are determined in the Screen Painter or in the Menu Painter. We recommend to assign function code "CS" in the Menu Painter to function key F2 in order to simultaneously assign the double-click function of the mouse to it. This allows you to assign dialog modules to the selection of input or output fields.
    Link: [Re: MODULE REQUEST;
    Thanks,
    reward If Helpful.

  • How to use database cursor in ABAP

    Hi all,
    I want to establish a connexion with another database system (Oracle) from SAP. Then i want to execute a cursor which is in a SQL package.
    The connexion is done sucssefuly but i don't know how to execute the cursor from SAP.
    The SQL package's definition that i have is :
    The name of package : pk_name
    The name of cursor : cursor c_dos(dat varchar, num varchar) return T_TABLE.
    Thx a lot for you help.

    hi Sourav,
    Check the sample program in SE38.
    in program name field give BCALV* press F4.
    BCALV_TEST_GRID_EVENTS
    It will give lot of example program.
    Reward if found helpful.
    Regards,
    Boobalan Suburaj

  • How to use REF cursor with toplink

    Hi,
    I have a stored proc has a out variable which is a REF CURSOR.
    How to read my cursor with toplink?

    I have got it. Here is the solution.
              UnitOfWork uow= dbSession.acquireUnitOfWork();
              StoredProcedureCall call = new StoredProcedureCall();
              call.setProcedureName("smart.getCompanyStruct");
              call.addNamedArgument("xnrid");
              call.useNamedCursorOutputAsResultSet("cpy");
              DataReadQuery query = new DataReadQuery();
              query.setCall(call);
              Vector parameters = new Vector();
              query.addArgument("xnrid");
              parameters.add(new Long(5009L));
              Vector obj = (Vector) uow.executeQuery(query, parameters);     
    Vector contains result ser of the cursor
    Gurcan

  • How to use/declare actual and formal paramters in ECC 6.0?

    Experts,
      I am new to ECC 6.0, and
    Please help me how to pass workarea in actual parameters ( I need to use USING/CHANGING or TABLES ?  please correct me ).
    And in FORM logic_4_ord_status,  how to declare work area and variables in formal parameters signature ???
    I have declared:
    TYPES : BEGIN OF ty_869_input_rec,
              rec_type(2)   TYPE c,
              cntrl_no(50)  TYPE c,
              rep_flag(1)   TYPE c,
              edi_tr_par(16) TYPE c,
              sap_cust_no(100) TYPE c,
              brd_idfr(4) TYPE c,
              canc_date(8) TYPE c,    " Promised to ship by date
              po_no(18) TYPE c,
              cust_cntrt_po_no(18) TYPE c,
              selection(2) TYPE c,
            END OF ty_869_input_rec.
    TYPES : BEGIN OF ty_870_output_rec,
              rec_type(2)       TYPE c,
              cntrl_no(50)      YPE c,
              rep_flag(1)       TYPE c,
              edi_tr_par(16)    TYPE c,
              sap_cust_no       TYPE vbeln_va,
              brd_idfr          TYPE vkorg,
              po_no             TYPE bstnk,
              cust_cntrt_po_no TYPE bstnk,
              selection(2)      TYPE c,
            END OF ty_870_output_rec.
    Internal table declarations.
    DATA : gt_869_input_rec TYPE TABLE OF ty_869_input_rec,
           gt_870_output_rec   TYPE TABLE OF ty_870_output_rec.
    Workarea declations.
    DATA : wa_869_input_rec   TYPE          ty_869_input_rec,
           wa_870_output_rec      TYPE          ty_870_output_rec.
      DATA :  lv_order_qty     TYPE wmeng,
              lv_cancelled1    TYPE wmeng,
              lv_cancelled2    TYPE wmeng,
            lv_delivery      TYPE lfimg,
              lv_open_qty      TYPE lfimg,
              lv_neworderqty   TYPE lfimg,
            lv_pickedqty     TYPE lfimg,
              lv_unshipped_qty TYPE lfimg.
         perform logic_4_ord_status
                             USING   wa_869_INPUT_REC
                                          lv_order_qty
                                          lv_delivery
                                          lv_open_qty
                                          lv_j_3acada
                                          lv_j_3arqda
                                          lv_cancelled1
                                          lv_zzactcnt
                                          lv_zzstatus
                             changing  wa_870_output_rec                        
    form logic_4_ord_status
                    using   p_wa_869_input_rec  type TY_869_input_rec
                                     p_lv_order_qty
                                     p_lv_delivery
                                     p_lv_open_qty
                                     p_lv_j_3acada
                                     p_lv_j_3arqda
                                     p_lv_cancelled1
                                     p_lv_zzactcnt
                                     p_lv_zzstatus
                    changing  p_wa_870_output_rec type TY_870_output_rec              
        IF  p_lv_delivery LE '0'
        AND p_lv_Open_Qty GT '0'
        AND ( p_wa_869_input_recu2013canc_date <> p_lv_j_3acada )
        AND ( p_lv_zzactcnt = 'F' OR  p_lv_zzactcnt = 0 ).
          p_wa_870_output_rec-shp_ord_status = 'RD' .
          p_wa_870_output_rec-order_qty      = p_lv_order_qty.
          p_wa_870_output_rec-open_qty       = p_lv_open_qty.
      FOR 1st 'SC'
        ELSEIF p_lv_delivery LE '0'
        AND    p_lv_Open_Qty GT '0'
        AND    ( p_lv_cancelled1 GT '0' )
        AND   ( p_lv_zzstatus = 'F'
             OR p_lv_zzactcnt = '0' ).
    I could not declare actual and formal parameters correctly .
    Kindly help me.
    I am getting error at p_wa_869_input_recu2013canc_date.
    Please validate me ...
    THANKS IN ADV.

    It depends on which BW environment has an RFC connection to the ECC environment you're activating the DataSource in. Typically, environments are paired, similar (but not always) like the depiction below:
    ECC Development <-> BW Development
    ECC QA <-> BW QA
    ECC Production <-> BW Production
    Best Practices suggest that a DataSource be activated and put on a transport in the ECC Development environment. Upon activation of the DataSource in ECC Development, replication of the DataSource in the BW Development environment can take place and Best Practices suggest putting the DataSource on a transport in BW. As the ECC transport is promoted throughout the ECC landscape, the BW transport is promoted throughout the BW landscape in order to keep them in sync.
    So, if the envrionment that you've just activated the DataSource has an RFC connection to your BW Production environment, you can replicate in BW Production and if that's your standard practice, then that's the way your should do it. It's typically, however, not considered a Best Practice to be able to create, update or delete in a production environment.

  • How to use Cursor Paramter

    Hi all,
    My query will written values by passing 5 parameter values.
    Now i want to use this query in plsql cursor, For that i need to use cursor parameter concepts and its very new to me. so pls any one help me how to use this cursor parameter to pass the values when i run my procedure.
    Regards
    Ajantha

    If you mean writing cursor with parameters you could try this way.
    CURSOR c1 (name VARCHAR2, salary NUMBER) IS SELECT ...
    --- open the cursor:
    OPEN c1(emp_name, 3000);
    Link for more info
    http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/06_ora.htm#36656
    Thanks

  • Using multi cursors i a function

    how to use two cursors in a pl/sql function.
    eg as : open c2;
    loop;
    fetch ....
    if c2%found then
    open c1;
    close c1.. ( how to close c1 and how to move to c2 again)
    again goto c2.
    how to define the structure.pls .
    thank u

    Hi APC thank u very much. One more doubt.
    in 1st cursor I mentioned query as
    select q_ord,q_rcv from dloc where order_no=p_no and q_ord=nvl(q_rcv,0).
    in 2nd sursor i mentioned it as
    select q_ord,q_rcv from dloc where order_no=p_no and q_ord>nvl(q_rcv,0)
    in function :
    open c2
    if c2%found then
    open c1
    if c1%found then
    return 0;
    i wrote like this. but I am not able to find the following requirement. I have already given this. pls check it and give me clue...pls
    select distinct 'x'
    from ordloc
    where order_no = P_ORD
    and qty_ordered > nvl(qty_received, 0)
    Please use this query to find the order is `OPEN` or `CLOSED`.
    Declare one more cursor for this query, open the cursor with the `IF` condition. If the cursor returns ‘x’ then `Block the Message` otherwise `Allow the Message`.
    here I wrote code for single cursor. i./e
    Create or replace Function AAAA(orderno number) return number is
    Cursor c1 is select distinct 'x'
    from ordloc
    where order_no = P_ORD
    and qty_ordered > nvl(qty_received, 0) ;
    dummy varchar2(1);
    begin
    Open c1;
    fetch c1 into dummy;
    close c1;;
    if dummy='X' then
    return 1;
    else
    return 0;
    end if;
    Exception
    when no_data_found then
    Message('No such Order');
    when others
    Message (sqlcode);
    end;
    but i'm not able to use 2nd cursor in this .plz let me know.
    thank u

  • How to use cursor data in more than one location in form?

    hi all.
    is it possible to make cursor as global or public in the form so i can use its data in more than location for testing like in buttons triggers.
    for example:
    if i declare the following cursor in "WHEN-NEW-FORM-INSTANCE" trigger
    CURSOR cur
    IS
    SELECT ID, NAME
    FROM PERSON;how can i use this cursor in other triggers in other buttons in the form?
    thanks

    kareem wrote:
    now i have the old data- from cursor and the new- from tableNo, you have not. When you open the cursor you get the state of the database at the current SCN.
    If you
    - open your cursor, fetch the data and close the cursor
    - update some data
    - open your cursor, fetch the data and close the cursor
    you will get the updated data from your cursor the second time (unless your update isn't a uncommited autonomous transaction but I wouldn't go down that route).
    You will have to save your data somewhere or you might take a look at flashback: http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm#i20759
    cheers

  • How to use cursor data in more than one location in the form?

    hi all.
    is it possible to make cursor as global or public in the form so i can use its data in more than location for testing like in buttons triggers.
    for example:
    if i declare the following cursor in "WHEN-NEW-FORM-INSTANCE" trigger
    CURSOR cur
    IS
    SELECT ID, NAME
    FROM PERSON;how can i use this cursor in other triggers in other buttons in the form?
    thanks

    kareem wrote:
    now i have the old data- from cursor and the new- from tableNo, you have not. When you open the cursor you get the state of the database at the current SCN.
    If you
    - open your cursor, fetch the data and close the cursor
    - update some data
    - open your cursor, fetch the data and close the cursor
    you will get the updated data from your cursor the second time (unless your update isn't a uncommited autonomous transaction but I wouldn't go down that route).
    You will have to save your data somewhere or you might take a look at flashback: http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm#i20759
    cheers

  • How to use a variable in a cursor?

    Hi,
    Is it possible to use a variable as condition for fetching data using cursors? The code works fine ( as shown) without using the clause 'where empno < 7600'. How can I use the variable 'stmt' in defining/fetching data by using cursor cur_1? My target is to get info for employee whose empno<7600. Any inputs would be appreciated.
    DECLARE
         STMT VARCHAR2(50) := 'EMPNO < 7600';
         CURSOR CUR_1 IS SELECT EMPNO, ENAME, JOB, MGR FROM EMP;
    BEGIN
         OPEN CUR_1;
         LOOP
              FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
              EXIT WHEN CUR_1%NOTFOUND;
              NEXT_RECORD;
         END LOOP;
         CLOSE CUR_1;
    END;

    Hi:
    You could use a CURSOR Parameter:
    DECLARE
    CURSOR CUR_1 (empno_in IN VARCHAR2) IS SELECT EMPNO, ENAME, JOB, MGR FROM EMP WHERE empno < empno_in;
    BEGIN
    OPEN CUR_1 (7600);
    LOOP
    FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
    EXIT WHEN CUR_1%NOTFOUND;
    END LOOP;
    CLOSE CUR_1;
    END;
    or a REF Cursor, like so:
    DECLARE
    TYPE CUR_1_TYPE IS REF CURSOR;
    CUR_1 CUR_1_TYPE;
    BEGIN
    OPEN CUR_1 FOR SELECT EMPNO, ENAME, JOB, MGR FROM EMP WHERE empno < 7600;
    LOOP
    FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
    EXIT WHEN CUR_1%NOTFOUND;
    END LOOP;
    CLOSE CUR_1;
    END;
    Note - these will run in SQL*Plus ... I believe you are using Oracle Forms as you had the NEXT_RECORD command in your example, and I had to remove it.

  • How to use a parameter passed to stored procedure in cursor?

    I am rather new to Oracle stored procedures and I'm sure that
    this is rather simple. Could someone tell me how to do the
    following: I would like to pass the variable status into my
    stored procedure and then use it in the where clause when
    defining my cursor. I have the stored procedure working 100%
    other than this small detail.
    CREATE OR REPLACE PROCEDURE p_report_starwood_exhibita2(hno
    VARCHAR2, cid INTEGER, kperiod INTEGER, status VARCHAR2, user
    VARCHAR2) IS
    BEGIN
    DECLARE
         CURSOR bid_cursor IS
         SELECT bm.hotelid
         FROM dbo.bidmaster bm
         WHERE bm.channelid = cid
         and bm.contractperiod = kperiod
         and bm.bidstatus like '&status'
    END;
    Thank you

    I am rather new to Oracle stored procedures and I'm sure that
    this is rather simple. Could someone tell me how to do the
    following: I would like to pass the variable status into my
    stored procedure and then use it in the where clause when
    defining my cursor. I have the stored procedure working 100%
    other than this small detail.
    CREATE OR REPLACE PROCEDURE p_report_starwood_exhibita2(hno
    VARCHAR2, cid INTEGER, kperiod INTEGER, status VARCHAR2, user
    VARCHAR2) IS
    BEGIN
    DECLARE
         CURSOR bid_cursor IS
         SELECT bm.hotelid
         FROM dbo.bidmaster bm
         WHERE bm.channelid = cid
         and bm.contractperiod = kperiod
         and bm.bidstatus like '&status'
    END;
    Thank you You can do something like this
    CREATE OR REPLACE PROCEDURE p_report_starwood_exhibita2(hno
    VARCHAR2, cid INTEGER, kperiod INTEGER, status VARCHAR2, user
    VARCHAR2) IS
    BEGIN
    DECLARE
    CURSOR bid_cursor (p_status varchar2) IS
    SELECT bm.hotelid
    FROM dbo.bidmaster bm
    WHERE bm.channelid = cid
    and bm.contractperiod = kperiod
    and bm.bidstatus like p_status
    END;
    and then in the BEGIN section do
    open bid_cursor(status)
    This should work.
    Regards
    Manoj

Maybe you are looking for

  • Portege M200: Booting from SD to external hard drive

    "M200 Recovery using Floppy or SD Card Posted: 15-Aug-2005 10:36 I am posting this in the hope it will help others seeking to use the recovery CD/DVD but without a bootable CD drive. I would like to acknowledge the Toshiba forum of TabletPCBuzz.com h

  • Jrun crash

    hi all i manage a server with cf8. my customer decided to move server to a cloud. from that moment, i lost my sleep... one or twice a day jRun gets the error "JRun closed connection". this is a little report of situation... any help is very appreciat

  • Infix Calculator (i/o problems)

    Greets all. My assignment is to write a program which evaluates an infix expression. I have no problem with this part, but how do I read the user input and know what each character is? I have this so far: StringTokenizer tokenizer = new StringTokeniz

  • Cant open the system file in Tiger

    Perhaps this is a question for the Classic forum. If so then I apoligize for this post. But I am trying to open the Mac OS 9 System file which will contain the "Quack" system beep and trying to convert that to a OSX format. But I get a message statin

  • Trnsporting of iboun and outbound Idoc interface to QA and PRD systems

    Hi, We have successfully completes the developement of our File to/From Idoc scenarios on Dev environment. Can some tell me how can I transport these to QA and PRD systems? How about the WE21 BD54(On Bus Sys) IDX1 and IDX2 configurations transports?