VBPA and VBAK query using OPEN CURSOR... anyway to skip buffer?

Hi all,
I have a query which VBPA inner join VBAK. In this query, I am using VBPA-KUNNR and VBPA-PARVW to query out data. I know VBPA holds a lot of data and querying in this way will be very heavy.
So I use OPEN CURSOR to query the SELECT .. INNER JOIN for these two tables...
It's fast for partners with few sales document.
But, i noticed the query will do a buffer before it process the query...
So my question is, is there a way to by-pass the buffer so it can immediately query?
Thanks,
William Wilstroth

Hi Sandeep,
I did put the BYPASSIUNG BUFFER syntax in the query. The result is still the same...
I wonder if it's just querying by VBPA-KUNNR and VBPA-PARVW is causing it? On the other hand, I think it's not because I am using VBPA-PARVW key field...
Hmmm... I wonder why in the first time query, it will go to buffer and it takes out some time...
Thanks,
William Wilstroth

Similar Messages

  • 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 create snapshot portlet and snapshot query using server API

    How to create snapshot portlet and snapshot query using server API
    Regards
    Dheeraj

    Hi Sebastian,
    I have used the query and it is working fine. but, How could i include the headers of the query also in to the Excel Sheet.
    RehaanKhan. M
    see the method discussed here
    http://sqlblogcasts.com/blogs/madhivanan/archive/2008/10/10/export-to-excel-with-column-names.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Opening two cursors using open cursor with bulk collect on colections ..

    Is it possible to have the implementatiion of using bulk collect with collections using two open cursors ..
    first c1
    second c2
    open c1
    loop
    open c2
    loop
    end loop
    close c2
    end loop;
    close c1
    what i found is for every outer loop of cursor c1 , cursor c2 is open and closed for every record.
    is this willl imporove the performace .?
    EXAMPLE:-
    NOTE: The relatoin between finc and minc is one to many ..finc is parent and minc is child
    function chk_notnull_blank ( colname IN number ) return number is
    BEGIN
    if ( colname is NOT NULL and colname not in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
    RETURN colname ;
    else
    RETURN 0;
    end if;
    END chk_notnull_blank;
    procedure Proc_AnnualFmlyTotIncSummary is
    CURSOR c_cur_finc IS SELECT FAMID FROM FINC ;
    CURSOR c_cur_minc IS SELECT FAMID, MEMBNO , ANFEDTX, ANGOVRTX, ANPRVPNX, ANRRDEDX, ANSLTX, SALARYX, SALARYBX, NONFARMX, NONFRMBX , FARMINCX, FRMINCBX, RRRETIRX, RRRETRBX, SOCRRX, INDRETX, JSSDEDX, SSIX, SSIBX from MINC minc WHERE FAMID IN ( SELECT FAMID FROM FINC finc WHERE minc.FAMID = finc.FAMID );
    v_tot_fsalaryx number := 0;
    v_tot_fnonfrmx number := 0;
    v_tot_ffrmincx number := 0;
    v_tot_frretirx number := 0;
    v_tot_findretx number := 0;
    v_tot_fjssdedx number := 0;
    v_tot_fssix number := 0;
    v_temp_sum_fsalaryx number := 0;
    v_temp_sum_fnonfrmx number := 0;
    v_temp_sum_ffrmincx number := 0;
    v_temp_sum_frretirx number := 0;
    v_temp_sum_findretx number := 0;
    v_temp_sum_fjssdedx number := 0;
    v_temp_sum_fssix number := 0;
    TYPE minc_rec IS RECORD (FAMID MINC.FAMID%TYPE, MEMBNO MINC.MEMBNO%TYPE , ANFEDTX MINC.ANFEDTX%TYPE, ANGOVRTX MINC.ANGOVRTX%TYPE , ANPRVPNX MINC.ANPRVPNX%TYPE , ANRRDEDX MINC.ANRRDEDX%TYPE , ANSLTX MINC.ANSLTX%TYPE, SALARYX MINC.SALARYX%TYPE , SALARYBX MINC.SALARYBX%TYPE , NONFARMX MINC.NONFARMX%TYPE , NONFRMBX MINC.NONFRMBX%TYPE, FARMINCX MINC.FARMINCX%TYPE , FRMINCBX MINC.FRMINCBX%TYPE , RRRETIRX MINC.RRRETIRX%TYPE , RRRETRBX MINC.RRRETRBX%TYPE, SOCRRX MINC.SOCRRX%TYPE , INDRETX MINC.INDRETX%TYPE , JSSDEDX MINC.JSSDEDX%TYPE , SSIX MINC.SSIX%TYPE , SSIBX MINC.SSIBX%TYPE );
    v_flag_boolean boolean := false;
    v_famid number ;
    v_stmt varchar2(3200) ;
    v_limit number := 50;
    v_temp_FAMTFEDX number := 0 ;
    v_temp_FGOVRETX number := 0 ;
    v_temp_FPRIVPENX number := 0 ;
    v_temp_FRRDEDX number := 0 ;
    v_temp_FSLTAXX number := 0 ;
    v_temp_FSALARYX number := 0 ;
    v_temp_FNONFRMX number := 0 ;
    v_temp_FFRMINCX number := 0 ;
    v_temp_FRRETIRX number := 0 ;
    v_temp_FINDRETX number := 0 ;
    v_temp_FJSSDEDX number := 0 ;
    v_temp_FSSIX number := 0 ;
    BEGIN
    OPEN c_cur_finc ;
    LOOP
         FETCH c_cur_finc BULK COLLECT INTO famid_type_tbl LIMIT v_limit;
         EXIT WHEN famid_type_tbl.COUNT = 0;
         FOR i in famid_type_tbl.FIRST..famid_type_tbl.LAST
         LOOP
         OPEN c_cur_minc ;
         LOOP
         FETCH c_cur_minc BULK COLLECT INTO minc_rec_type_tbl LIMIT v_limit;
         EXIT WHEN minc_rec_type_tbl.COUNT = 0;
              FOR j IN minc_rec_type_tbl.FIRST..minc_rec_type_tbl.LAST
              LOOP
              if ( famid_type_tbl(i) = minc_rec_type_tbl(j).FAMID ) THEN
              v_temp_FAMTFEDX := v_temp_FAMTFEDX + chk_notnull_blank(minc_rec_type_tbl(j).ANFEDTX );
              v_temp_FGOVRETX := v_temp_FGOVRETX + chk_notnull_blank(minc_rec_type_tbl(j).ANGOVRTX);
              v_temp_FPRIPENX := v_temp_FPRIPENX + chk_notnull_blank(minc_rec_type_tbl(j).ANPRVPNX);
              v_temp_FRRDEDX := v_temp_FRRDEDX + chk_notnull_blank(minc_rec_type_tbl(j).ANRRDEDX);
              v_temp_FSLTAXX := v_temp_FSLTAXX + chk_notnull_blank(minc_rec_type_tbl(j).ANSLTX );
              v_temp_FSALARYX := v_temp_FSALARYX + chk_notnull_blank(minc_rec_type_tbl(j).SALARYX ) + chk_notnull_blank(minc_rec_type_tbl(j).SALARYBX);
              v_temp_FNONFRMX := v_temp_FNONFRMX + chk_notnull_blank(minc_rec_type_tbl(j).NONFARMX) + chk_notnull_blank(minc_rec_type_tbl(j).NONFRMBX);
              v_temp_FFRMINCX := v_temp_FFRMINCX + chk_notnull_blank(minc_rec_type_tbl(j).FARMINCX) + chk_notnull_blank(minc_rec_type_tbl(j).FRMINCBX );
              v_temp_FRRETIRX := v_temp_FRRETIRX + chk_notnull_blank(minc_rec_type_tbl(j).RRRETIRX) + chk_notnull_blank(minc_rec_type_tbl(j).RRRETRBX ) + chk_notnull_blank(minc_rec_type_tbl(j).SOCRRX);
              v_temp_FINDREXT := v_temp_FINDRETX + chk_notnull_blank(minc_rec_type_tbl(j).INDRETX);
              v_temp_FJSSDEDX := v_temp_FJSSDEDX + chk_notnull_blank(minc_rec_type_tbl(j).JSSDEDX);
              v_temp_FSSIX := v_temp_FSSIX + chk_notnull_blank(minc_rec_type_tbl(j).SSIX ) + chk_notnull_blank(minc_rec_type_tbl(j).SSIBX);
              END IF;
              END LOOP;
         END LOOP ;
         CLOSE c_cur_minc;
         UPDATE FINC SET FAMTFEDX = v_temp_FAMTFEDX WHERE FAMID = famid_type_tbl(i);
         END LOOP;
    END LOOP;
    CLOSE c_cur_finc;
    END;
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    v_err_code := SQLCODE;
    v_err_msg := substr(SQLERRM, 1, 200);
    INSERT INTO audit_table (error_number, error_message) VALUES (v_err_code, v_err_msg);
    error_logging(p_error_code => substr(sqlerrm,1,9), p_error_message => substr(sqlerrm,12), p_package =>'PKG_FCI_APP',p_procedure => 'Proc_Annual_Deductions_FromPay ' , p_location => v_location);
    end Proc_AnnualFmlyTotIncSummary ;
    Is the proga efficient and free from compilation errors ..?
    thanks/kumar
    Edited by: kumar73 on Sep 22, 2010 12:48 PM

    function chk_notnull_blank ( colname IN number ) return number is Maybe this function should have its own forum:
    how to use case in this program
    Re: how to declare a formal parameter in a function of type record and access ?
    Re: how to define a function with table type parameter
    Re: creation of db trigger with error ..
    Re: How to write a trigger for the below scenario
    how to improve the code using advanced methods
    yours advice in improving the coding ..
    How to use bulk in multiple cursors !!
    ;-)

  • Integration between PS and MS project using open PS

    Hello all
    We have a requirement to interface MS Project with SAP PS using open PS that is a standard SAP provided interface.Since i dint work on this before please help me in answering the below questions:These are the clients requirement.
    1. Methodology of installing this interface.
    2. Projects created in MS Project should create a project in SAP R3 and vice versa.
    3. Projects changed in MS Projects should go and update projects in SAP R3 and vice versa.
    4. Selective data transfer from MS project to SAP R3, for example we want to update only a portion of the project.
    5. How easy it is to download MS Project, project to SAP and vice versa. I remember in olden days
    downloading from SAP R3 was easy where-as uploading was pain. I am sure SAP would have addressed it.
    6 Any other information that you think would help us understand this interface better from installation,
    usability and maintenance, BAPI perspective.
    Thanks

    hi,
    kindly go through the link..it was and is still useful in regard to open ps :
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5037d0e8-8bc2-2a10-6fb3-c4833289bb66
    Regards,
    Ajit

  • Help with supply and demand query using monthly buckets

    I'm working on a query bound for Discoverer which pulls the aggregated supply and demand for an item and buckets it into months. So for any given item, I need to show the item, onhand, cost, aggregated supply (planned orders, requisitions, pos), and aggregated demand (planned order demand, jobs) - all bucketed by months.
    The code below works okay to find all of the data for July, but I also need to show August and September. I'm thinking I could use a union but am reluctant because the query already runs kind of slow and I'm not sure if I'm on the right track.
    Database Server
    RDBMS : 10.2.0.3.0
    Oracle Applications : 11.5.9
    -Tracy
    select
          item.inventory_item_id, item.organization_code, item.item, item.description
        , item.make_buy,item.planner_code
        , planned.compile_designator, planned.order_type_text, sum(planned.quantity_rate)planned_total
        , planned.mrp_sugg_due_month
        , sum(job.required_quantity-job.quantity_issued)job_open, job.required_month
        , onhand.total_qoh
        , purchase.item_revision prev, purchase.promised_month, purchase.ship_to_organization_id 
        , sum((purchase.quantity-purchase.quantity_cancelled)-purchase.quantity_received)po_open  
        , req.item_revision rrev, req.destination_organization_id, req.org_id, req.need_by_month
        , sum((req.quantity-req.quantity_cancelled)-req.quantity_delivered)req_open
        , cost.item_cost,cost.cost
    from
    --item--
    (select mtl.inventory_item_id, mtl.segment1 item,mtl.description,decode(mtl.planning_make_buy_code,1,'Make',2,'Buy') make_buy
            ,mtl.organization_id, mtp.organization_code, mtl.planner_code
           ,to_char(add_months(sysdate,+1),'YYYY_MM')month1, to_char(add_months(sysdate,+2),'YYYY_MM')month2
           ,to_char(add_months(sysdate,+3),'YYYY_MM')month3
    from    inv.mtl_system_items_b mtl, inv.mtl_parameters mtp
    where    mtl.organization_id = mtp.organization_id
    )item,
    --planned orders - 3 months --
    (select compile_designator,organization_id,inventory_item_id,order_type_text,nvl(quantity_rate,0)quantity_rate,new_due_date
           ,to_char(trunc(new_due_date,'MM'),'YYYY_MM')mrp_sugg_due_month
    from   apps.mrp_orders_sc_v
    where  order_type_text in ('Planned order','Planned order demand')
    and    to_char(trunc(new_due_date,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
    and    to_char(trunc(new_due_date,'MM'),'YYYY_MM') >=  to_char(:Month,'YYYY_MM')
    )planned,
    --jobs - 3 months--
    (select organization_id,wip_entity_name job, inventory_item_id,concatenated_segments,nvl(required_quantity,0)required_quantity
            ,nvl(quantity_issued,0)quantity_issued, date_required,to_char(trunc(date_required,'MM'),'YYYY_MM') required_month
            ,wip_entity_id,creation_date, wip_job_status
    from    apps.wip_requirement_ops_inq_v
    where   primary_item_id <>inventory_item_id
    and     wip_job_status not in ('Closed','Cancelled','Complete')
    and     to_char(trunc(date_required,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
    and     to_char(trunc(date_required,'MM'),'YYYY_MM') >= to_char(:Month,'YYYY_MM')
    )job,
    --qty onhand--
    (select  inventory_item_id,organization_id,sum(nvl(transaction_quantity,0))total_qoh
    from     inv.mtl_onhand_quantities_detail
    group by inventory_item_id, organization_id
    )onhand,
    -- po - 3 months--
    (select pol.item_id, pol.item_revision, nvl(pll.quantity,0)quantity, nvl(pll.quantity_received,0)quantity_received
          , nvl(pll.quantity_rejected,0),nvl(pll.quantity_cancelled,0)quantity_cancelled,poh.segment1 po_num
           ,pll.promised_date, to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')promised_month
           ,pll.shipment_num,pll.ship_to_organization_id 
    from   po.po_lines_all pol, po.po_headers_all poh, po.po_line_locations_all pll
    where  poh.po_header_id = pol.po_header_id
    and    pol.po_header_id = pll.po_header_id
    and    pol.po_line_id = pll.po_line_id
    and    pol.cancel_flag != 'Y'
    and    pol.item_id is not null
    and    to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')<= to_char(add_months(:Month,+2),'YYYY_MM')
    and    to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')>=  to_char(:Month,'YYYY_MM')
    )purchase,
    --reqs - 3 months--
    (select prh.segment1 req_number,nvl(prl.quantity,0)quantity,nvl(prl.quantity_delivered,0)quantity_delivered
           ,nvl(prl.quantity_cancelled,0)quantity_cancelled
           ,prl.destination_organization_id,prl.org_id,prl.item_id,prl.item_revision,prl.need_by_date
           ,to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM')need_by_month
    from   po.po_requisition_headers_all prh, po.po_requisition_lines_all prl
    where  prh.requisition_header_id = prl.requisition_header_id(+)
    and    nvl(prl.cancel_flag,'N') !='Y'
    and    prh.authorization_status != 'CANCELLED'
    and    to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
    and    to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM') >=  to_char(:Month,'YYYY_MM')
    )req,
    --cost--
    (select msib.inventory_item_id,msib.organization_id,cqm.material_cost,cic.item_cost
    ,(case when cqm.material_cost=0 then cic.item_cost else cqm.material_cost end) cost, cqm.cost_group_id
    from inv.mtl_system_items_b msib
         ,(select cql.cost_group_id,cql.inventory_item_id,cql.organization_id,cql.layer_quantity,cql.material_cost,mp.organization_code
             from bom.cst_quantity_layers cql, inv.mtl_parameters mp
            where mp.default_cost_group_id = cql.cost_group_id) cqm
        ,bom.cst_item_costs cic
    where msib.inventory_item_id = cqm.inventory_item_id(+)
    and msib.organization_id = cqm.organization_id(+)
    and msib.inventory_item_id = cic.inventory_item_id(+)
    and msib.organization_id = cic.organization_id(+)
    )cost
    where item.inventory_item_id = job.inventory_item_id(+)
    and   item.organization_id = job.organization_id(+)
    and   item.month1 = job.required_month(+)  -- 2009_07 --
    and   item.inventory_item_id = onhand.inventory_item_id(+)
    and   item.organization_id = onhand.organization_id(+)
    and   item.inventory_item_id = purchase.item_id(+)
    and   item.month1 = purchase.promised_month(+)  -- 2009_07 --
    and   item.inventory_item_id = req.item_id(+)
    and   item.month1 = req.need_by_month(+)  -- 2009_07 --
    and   item.inventory_item_id = cost.inventory_item_id(+)
    and   item.organization_id = cost.organization_id(+)
    and   item.inventory_item_id = planned.inventory_item_id(+)
    and   item.organization_id = planned.organization_id(+)
    and   item.month1 = planned.mrp_sugg_due_month(+)  -- 2009_07 --
    and   item.make_buy = 'Buy'
    and   item.item in ('161309040','744L755','150-GFM') --test items --
    group by item.inventory_item_id,item.organization_code,item.item,item.description,item.make_buy,item.planner_code
          ,job.required_month ,onhand.total_qoh , purchase.item_revision,  purchase.promised_month
            ,purchase.ship_to_organization_id  ,cost.item_cost,cost.cost
           ,req.item_revision, req.destination_organization_id,req.org_id,req.need_by_month
           ,planned.compile_designator,planned.order_type_text,planned.mrp_sugg_due_month
    order by item.organization_code,item.item

    Hi,
    Six things:
    (1) Where are the one-to-many relationships between your tables? If a single row in mtl can match two (or more) rows in mrp, and can also match two (or more) rows in wip, then it looks like, when you join both of them them, you'll have a chasm trap, that is, you'll get all the matching rows from mrp paired with all matching rows from wip. Are you sure your existing query is producing the right results?
    Are there one-to-many relationships with the other tables in your original query?
    (2) Are your DATEs always at midnight? If not, avoid using BETWEEN and LAST_DAY for DATE comparisons: otherwise you'll miss everything between 00:00:01 and 23:59:59 on the last day.
    That is, instead of
    and     mrp.new_due_date(+) BETWEEN :Month AND LAST_DAY(ADD_MONTHS(:Month,2))ypou should say
    and       mrp.new_due_date (+)     >= :Month
    and       mrp.new_due_date (+)     <  ADD_MONTHS (:Month, 3)(3) The basic way to pivot the months of mrp_due_date is:
    SELECT    ...
    ,       NVL ( SUM ( CASE
                     WHEN  mrp.new_due_date >= :month
                     AND   mrp.new_due_date < ADD_MONTHS (:month, 1)
                     THEN  mrp.quantity_rate
                    END
               , 0
               )          AS mrp_qty_0
    ,       NVL ( SUM ( CASE
                     WHEN  mrp.new_due_date >= ADD_MONTHS (:month, 1)
                     AND   mrp.new_due_date <  ADD_MONTHS (:month, 2)
                     THEN  mrp.quantity_rate
                    END
               , 0
               )          AS mrp_qty_1When you do this, do not GROUP BY TRUNC (mrp.new_due_date, 'MM').
    The code above does two months: I'm sure you get the idea for how to do more.
    To get dynamic column headings (such as Jun_2009 or "2009-06" instead of the generic mrp_qty_o) requires dynamic SQL. The best way to do dynamic SQL depends on the tool that is producing the query (e.g. SQL*Plus). What are you using? Are you willing to change, if it helps?
    (4) Displaying separate columns from one row as a single column on multiple rows is called unpivoting. How badly do you want to do that? Your query would be simpler and faster if the output had only one row per group (rather than one row for mrp_qty and another row for wip_wty). That one row could have six columns (e.q. June_mrp, June_wip, July_mrp, July_wip, August_mrp and August_wip) instead of three. Depending on your front-end tool, you might even be able to wrap the single row of output so that it always appeared as two rows, each with three columns.
    (5) Sorry I told you to do
    and     mrp.order_type_text(+) in (...)I never use the + outer-join notation any more, so I forgot about the ORA-01719 error. There's no problem having an outer-join condition like that using ANSI notation. (One more reason to switch.)
    (6) As you noticed, this site doesn't like to print the &lt;&gt; inequality operator, even inside tags.
    Use the equivalent != operator instead, when posting on this site.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Link between vbpa and vbak tables

    Hi,
    I would like to know the link between VBAK and VBPA tables.
    VBELN field in both these fields are the same?
    If I give the VBELN field got from the VBAK table into the VBPA table will I get the  customer number(KUNNR) of that particular SAles document?
    Thanks & Regards,
    Soumya.

    You can get Kunnr directly from the VBAK table, if you wanna do the Join still you can go forward and do it there is no harm but remeber to give the Partner Function(PARVW) as well as VBELN.
    Hope That Helps
    Anirban M.

  • Adobe is simply a rip off and people should use open source programs

    Every time I go to use something you leaches are trying to suck more money from me.  I am moving everything to open source.  Screw you guys.

    Hi John,
    I'm so sorry to hear of your frustration. Is there something in particular I can assist you with?
    Please let me know.
    Looking foward to hearing back from you.
    Kind regards, Stacy

  • How  to Pass String array from Java to PL/SQL  and this use in CURSOR

    hi,
    I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
    This array containing like (SYMPTOM ) to be returned from the java to the
    pl/sql (I am not querying the database to retrieve the information).
    I cannot find an example on this. I will give the PL/SQL block
    create or replace procedure DISEASE_DTL<*** String Array ***> as
    v_SYMPTOM number(5);
    CURSOR C1 is
    select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
    where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
    group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
    order by a.DISEASE_NAME ;
    begin
    for C1rec IN C1 loop
    select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
    insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
    values (SL_ID_SEQ.nextval,
    C1rec.DISEASE_NAME,
    (4/v_SYMPTOM), --------**** 4 is no of array element (n)************
    (1-(4/v_SYMPTOM)));
    end loop;
    commit;
    end DISEASE_DTL;
    Please give the proper solution and step ..
    Thanking you,
    Asish

    I've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
    http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/

  • Reg Open Cursor Concept

    Friends,
    Please kindly help me to analyse this dump.
    In BI end routine select * query has been written to fetch values from active dso . They are using non primary key in the where condition.
    More than 2 crore 20 million records were avaialble in that DSo for that condtion. While executing this query its going to dump.
    If i move ahead with Open cursor set Hold will this query work fine and using open cursor set hold can i fetch  2 crore 20 million records.
    In dump its shwoing to check the parameters : ztta/roll_area  ,ztta/roll_extension and abap/heap_area_total . Even i checked those parametrs in RZ11. The curent val is sufficient.
    Please kindly advice me for this dump and will open cursor set hold avoid the dump for  2 crore 20 million  records.
    Thanks
    Edited by: Suhas Saha on Sep 29, 2011 1:06 PM

    I am not completely convinced:  the difference depends on the task which has to be done with the records of a package.
    If the records are processed and the result must be written to the database into another table, then it will be necessary to COMMIT the changes, otherwise the 20.000.000 records will cause an overflow in the redo-logs of the database.
    => Only the OPEN CURSOR WITH HOLD will survive the DB-Commit.
    The SELECT ... PACKAGE SIZE is simpler and can be used, if the result is further processed and reduced in size, which makes it possible to keep all data in memory (no intermediate DB-COMMITs are necessary) .
    I would assume that case is the less frequent use case.
    Siegfried

  • Open cursors exceeded - common problem, different scenario

    I searched both the web and the java forums and found the "maximum open cursors exceeded" to be a very common problem, one in which I have, but I can't seem to solve it and I was wondering if the way I am doing certain things are causing it.
    Here is my program. I have a java server running that is acting as a midway between a java applet and an Oracle database. Since many users will most likely be using the applet, and since the applet has the ability to alter data in the database, I wanted to Synchronize my database connections.
    So because of this, my server has a static class with all the database calls, including a connection call that connects to the database when it is first started up. Also, I return ResultSets to the server, but I never close either my ResultSet or my Statement. I do this because I only have one global of each of them. Otherwise I would have to close them from the server, and this worries me as far synchronization goes. Thus, with a global statement, I am just reinstantiating it every time. This may very well be my problem.
    Should I?
    1. Not have a single connection to the database but instead create a new connection every time a database call is made?
    2. Do not make the resultset and statement global. (And if this is yes, how would I go about closing them after I return the result set to the server).
    3. Leave the resultset and statement global but go ahead and try to close them from the server.
    4. Or any combination of the above.
    Thanks. I appreciate any help advance. This problem has been driving me insane the last couple of days. If it would help to post my database connections code then I will gladly do so.

    Hmmm. I have worked on it all day and still have nothing. If anyone has even a shred of help, that would be greatl appreciated. I am going to just go ahead and post my code just in case that helps anyone.
    import java.net.*;
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    class DBOracleCon
         final static String          DBHostName = "hostname",
                             DBPortNumber = "12345",
                             DBId ="myid";
         final static String          UserName = "user",
                             Password = "password";
         private static Connection con;     
         private static Statement stmt;     
         private static ResultSet rs;
         static protected void dbConnection ()
              try
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        String dbConnectString =
                        "(DESCRIPTION=(ADDRESS=(HOST=" + DBHostName + ")"+
                        "(PROTOCOL=tcp)(PORT="+ DBPortNumber + "))"+
                        "(CONNECT_DATA=(SID="+ DBId + ")))";
                   con = DriverManager.getConnection(
                            "jdbc:oracle:thin:@"+dbConnectString,
                            UserName, Password);
                          con.setAutoCommit(false);
              catch (Exception e)
                   System.out.println ("Connection Error:" + e);
         static public synchronized Connection returnConnection ()
              return con;
         static protected synchronized ResultSet executeQuery (String query)
              try
                   stmt = con.createStatement();
                   //System.out.println ("QUERY: " + query);
                   rs = stmt.executeQuery (query);
                   return rs;
              catch (Exception e)
                   System.out.println (e);
                   e.printStackTrace();
                   return null;
         static protected synchronized ResultSet executeQuery (PreparedStatement ps)
              try
                   rs = ps.executeQuery();
                   return rs;
              catch (Exception e)
                   System.out.println (e);     
                   e.printStackTrace();
                   return null;
         static protected synchronized void executeUpdate (String query)
              try
                   stmt = con.createStatement();
                   System.out.println ("UPDATE: " + query);
                   stmt.execute (query);
                   commit();
              catch (Exception e)
                   System.out.println (e);
                   e.printStackTrace();
         static protected void executeUpdate (PreparedStatement ps)
              try
                   ps.executeUpdate();
                   commit();
              catch (Exception e)
                   System.out.println (e);     
                   e.printStackTrace();     
         static private void commit ()
              try
                   stmt = con.createStatement();
                   stmt.execute ("commit");
              catch (Exception e)
                   System.out.println (e);
    }Thanks.

  • Cannot figure out why "ORA-01000 Maximum open cursors" is shown...

    Hello there ...
    I am programming a PL/SQL Code that is throwing 0RA-01000 Maximum Open Cursors Exceeded.
    Having already read quite a lot about ORA-01000 errors, I know I should be closing cursors, and have already tried setting OPEN_CURSORS parameter to a high number (1000).
    I declared a lot of procedures in my pl/sql, each of which uses one cursor since i am working with a non-Oracle table linked by ODBC ... and each procedure sometimes does thousands of inserts -- but all WITHIN the explicit cursors. The explicit cursors are not declared within each loop.
    I already checked the code many times, and made sure all open cursors are closed. In addition, I also verified the numberopen cursors generated by the PL/SQL by running the following SQL after every procedure i run... and outputting it... and it appears the value just keeps on increasing, even though I had explicitly closed all the cursors in all the earlier procedures.
    What is funny is that the most number of cursors reported by the code below only hits 150+ cursors. Nowhere near the 1000 open_cursors limit per session.
    select a.value into strtxt --, b.name        
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;When I run the procedures separately though, all the procedures run smoothly (even when I had not yet updated the open_cursors parameter).
    I was thinking of the following, but maybe you have some other ideas?
    Does this have anything to do with my procedures not being stored procedures?
    Or should i be committing records within my procedures instead of out of it?
    I really have run into a wall and would really appreciate any tips or helps on this. Thanks in advance!
    My basic pl/sql code looks like below. I did not give the actual details cause it will be too long (up to 5000 lines).
    DECLARE
    PROCEDURE proc1
    IS
        CURSOR cur_hca
           is
               select ...from..where;
       TYPE cur_hca_fetch
            Is TABLE OF cur_hca%ROWTYPE
                INDEX BY PLS_INTEGER;
        temp_collect cur_hca_fetch;
    BEGIN
       open cur_hca;         --cur_hca is the cursor name.
                                      --i use exactly the same cursor name in the other procedures
          loop
             fetch cur_hca bulk collect into temp_collect LIMIT 1000;
             exit when temp_collect.count=0
             for indx in 1 .. temp_collect.count
                loop
                  ...run some sql
                end loop;
          end loop;
      close cur_hca;
    END proc1;
    PROCEDURE proc2   --almost the same as above the only changes are the query for the
                                 -- cursor and the sql that happens for each record
    IS
    BEGIN
       open cur_hca;         --cur_hca is my cursor name
          loop
          end loop;
      close cur_hca;
    END proc2;
    ... up to 40 other very similar procedures
    BEGIN
       proc1;
       commit;
       select a.value into strtxt
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;
      DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc1: ' || strtxt); 
       proc2;
       commit;
       select a.value into strtxt
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;
       DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc2: ' || strtxt); 
       ... 40 other procedures
    END;Edited by: user4872285 on May 6, 2013 6:49 PM
    Edited by: user4872285 on May 6, 2013 7:01 PM
    Edited by: user4872285 on May 6, 2013 8:02 PM
    Edited by: user4872285 on May 6, 2013 8:03 PM

    PL/SQL code usually leaks reference cursors and DBMS_SQL cursors - as the ref cursor/DBMS_SQL interface used has a global (session static) scope.
    PL/SQL has an intelligent garbage collector that will close local implicit and explicit cursors, when the cursor variable goes out of scope.
    If you define an explicit cursor globally (package interface), then it can only be opened once. The 2nd attempt results in a ORA-06511: PL/SQL: cursor already open exception. So code cannot leak explicit cursors as code cannot reopen an existing opened explicit cursor.
    I have never seen Oracle leaking cursors internally. So I would be hesitant to call what you are seeing, a bug. If your code is using explicit cursors (even static/global ones), your code cannot leak these cursors, even if your code does not close them. Worse case - the cursor remains open, however new copies cannot be created while it is open.
    So I think your are looking at the wrong thing - explicit cursors. These are not the cursors that are leaking in my view (simply because code cannot reuse and open an already opened explicit cursor). Here is an example:
    SQL> show parameter cursors
    NAME                                 TYPE        VALUE
    open_cursors                         integer     300
    session_cached_cursors               integer     50
    // procedure that seems to "leak" an explicit cursor handle
    // as it does not explicitly closes the handle
    SQL> create or replace procedure CursorUse is
      2          cursor c is select e.* from emp e;
      3          empRow  emp%RowType;
      4  begin
      5          open c;
      6          fetch c into empRow;
      7          --// not closing explicit cursor handle
      8          --// and going out-of-scope
      9  end;
    10  /
    Procedure created.
    // current session stats
    SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
    NAME                                  VALUE
    opened cursors cumulative                91
    opened cursors current                    2
    // execute proc that "leaks" a cursor, 10000 times
    SQL> begin
      2          for i in 1..10000 loop
      3                  CursorUse;
      4          end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    // no errors due to cursor leakage
    // session stats: no cursor leakage occurred as
    // PL/SQL's garbage collector cleaned (and closed)
    // cursor handles when these became out-of-scope
    SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
    NAME                                  VALUE
    opened cursors cumulative            10,095
    opened cursors current                    2
    SQL> So the cursor leakage you are seeing is caused by something else... so what else is part of the code, or the session, that you have not yet mentioned?

  • Pro*C SEGFAULT on open cursor

    Hi,
    I have query like below.
    SELECT count(*) from table1 where
    batch_id in (select unique batch_id from table1 where <condition on dates>)
    and <condition2>;
    Its prepared fine and when opening, its getting core dump with segfault.
    The table has ~8cr rows. When I execute that query on SQL prompt, its taking around 2hrs to get the result.
    But, I am calling that query from a CGI program which will run for some time and after that , when opening cursor for the query, its failed.
    I cannot give code details as its restricted from my system.
    Any clues, really appreciated. Thnx in adv.

    Can you reproduce the problem in a small test program that uses only generic data (and is therefore not sensitive)?
    We will need to see some code to help you solve the problem, so if the corporate policy is that ALL code written by employees is classified, then you'll need to work with your management to determine how to get a test program out for the purposes of debugging. There's usually some restriction in the rules for cases like this.
    What does ~8cr mean? I guess ~ means approximately, and 8 is obvious, so the question boils down to how many is 1cr.

  • Maximum open cursors exceeded problem

    hi,
    I am connecting to Oracle 8i (8.1.6 ) using JDBC2.0. I have a
    block of code which does the following:
    Open connection to database, create a Statement object say stat
    and a Prepared Statement object say pStat
    pStat.execute()
    while(condition)
    stat.executeUpdate(string);
    pStat.close();
    stat.close()
    Close connection
    Multiple execution of the block gives ORA-01000 error. I use
    select user_name, count(*) num from sys.v_$open_cursor group by
    user_name;
    to check for open cursors and find that no open cursors result
    from block. The maximum # of open cursors is set to 100.
    Please help!
    Regards,
    Pratibha

    If that were true, then connection pooling would never work. I
    think the problem is:
    while(condition){
    stat.executeUpdate(string);
    Oracle is creating a new process (cursor) for each call to
    executeUpdate, which is never being released throught the whole
    looping process. What would be better is:
    while(condition){
    stat = conn.createStatement();
    int result = stat.executeUpdate(string);
    stat.close();
    conn.commit();
    You have to destroy the connection, not just close it.
    rgds, APC

  • How can you set the max row for a 'open cursor' in a stored proc?

    I would like to know how can you set the maximum amount of row returned in a resultset coming from a stored proc?
    You can do it via JDBC with cStatement.setMaxRows(10); but it works only for select that you do via JDBC...
    I would like the same functionality using open cursor inside a stored proc...
    Thanks...

    is "where ROWNUM <= 10" the equivalent of "cStatement.setMaxRows(10);" because the ROWNUM as problem with the ORDER BY clause and the setMaxRows() as no problem...

Maybe you are looking for

  • How can i text through my computer(through my apple ID) to my text messages on phone

    i ahve seen this done but I can not seem to figure it out. i am trying to text through my computer. can anyone help?

  • Can't Export please help

    I am having a lot of trouble exporting my final project; I need to export it to a DV tape (North America), and each time i try it comes out slow and choppy on the camera, and always gets frozen on the same image while audio runs till the end. I follo

  • Petty string

    hi sir here i have write a code for petty string it throughs an exception of index out of bond sir plz help not me to solve this problem thanx * petty.java * Created on August 13, 2007, 6:06 AM * To change this template, choose Tools | Template Manag

  • IPhone stuck on plug into iTunes screen

    I pugged my iPhone in to iTunes on my computer the other day and it worked fine until an unknown error popped up mid update so I pressed cancel and unplugged my iPhone but on my iPhone it just told me to plug my phone into iTunes but every time I plu

  • Crash when importing Outlook contacts

    I have tried to use the import of outlook contacts (OL 2007) in PSE 9. Everytime I select Outlook as the source, bam, PSE stops working. W7 64 is the OS. Any ideas? Really silly to have to re-enter contacts from outlook as this was a feature I was wa