Cursor using exception issue reg

Dear all,
I have created one procedure and it is working perfectly ,but i want two point to be included in this code
point 1: i want to trap any error through Exception which i need to include in this code
so in which section i need to include the exception section and what type of useful exception i should include.
point 2: i want status of no of row being updated while processing
i need ur suggestion kindly
regards
Laxman
create or replace procedure freereq24hr
as
begin
FOR mtid_cur_rec in (select a.miniteamid from auto_miniteam a,miniteam m
where job_type=5 and
a.miniteamid=m.miniteamid) LOOP
FOR age_cur_rec in (SELECT requestID
                    FROM Request
                    WHERE     miniteamid IN     (      
SELECT      childMiniTeamID
FROM MiniTeamTree
                    WHERE      childMiniteamID = mtid_cur_rec.miniteamid AND
                    parentMiniteamID IN(mtid_cur_rec.miniteamid)
                         ) AND
                    requestTypeCode = 1 AND
                    statusCode IN (2,3) AND
                         assigned_PersonID is NULL AND
                    lastmoddate < sysdate - 1) LOOP
                    IntNotesHistoryInsert(age_cur_rec.requestid,'FREE REQUEST 24 HR');
UPDATE Request
          SET statusCode = 1, assigned_PersonID = NULL
WHERE requestID = age_cur_rec.requestid;
commit;
END LOOP;
END LOOP;
END;

point 1: i want to trap any error through Exception which i need to include in this code
so in which section i need to include the exception section and what type of useful exception i should include. What kind of error do you expect? Seeing your code i dont think you need to handle any specific exception.
>
point 2: i want status of no of row being updated while processing You can use sql%rowcount to get that details.
create or replace procedure freereq24hr
as
begin
FOR mtid_cur_rec in (select a.miniteamid from auto_miniteam a,miniteam m
where job_type=5 and
a.miniteamid=m.miniteamid) LOOP
FOR age_cur_rec in (SELECT requestID
                        FROM Request
                        WHERE     miniteamid IN     (      
SELECT      childMiniTeamID
FROM MiniTeamTree
                        WHERE      childMiniteamID = mtid_cur_rec.miniteamid AND
                        parentMiniteamID IN(mtid_cur_rec.miniteamid)
                         ) AND
                        requestTypeCode = 1 AND
                        statusCode IN (2,3) AND
                         assigned_PersonID is  NULL AND
                        lastmoddate < sysdate - 1) LOOP
                        IntNotesHistoryInsert(age_cur_rec.requestid,'FREE REQUEST 24 HR');
UPDATE Request
                   SET statusCode = 1, assigned_PersonID = NULL
WHERE requestID = age_cur_rec.requestid;
commit;
END LOOP;
END LOOP;
END;But in general i would rewrite your code to avoide two for loop and just have a single thing.
create or replace procedure freereq24hr
as
begin
  for i in (
             select requestId
               from request r
               join miniteamtree m
                 on r.miniteamid = m.childminiteamid
               join auto_miniteam a
                 on a.miniteamid = m.childminiteamid
                and a.miniteamid = m.parentminiteamid
               join miniteam mi
                 on a.miniteamid = mi.miniteamid
              where job_type = 5
                and requestTypeCode = 1
                and statusCode IN (2,3)
                and assigned_PersonID is NULL
                and lastmoddate < sysdate - 1
  loop
    IntNotesHistoryInsert(i.requestid,'FREE REQUEST 24 HR');
    UPDATE Request
       SET statusCode = 1, assigned_PersonID = NULL
     WHERE requestID = i.requestid;
    dbms_output.put_line('Number of row updated for requestID ' || i.requestID || ' is ' || sql%rowcount);
  end loop;
  commit;
end;Also i have taken the commit outside the loop. Dont perform commit inside the loop.
When you use dbms_output.put_line you can see the output only when the procedure completes the execution. So if you want to se the status during the procedure is running you may want to use DBMS_APPLICATION_INFO or create your own logging procedure and log the details.

Similar Messages

  • 'number of open cursors exceeded' exception - 10.3.1

    Hi All,
    We have may DynamicSQL statements fired from our processes due to which we are getting 'number of open cursors exceeded' exception. We don't want to increase the limit of the maximum open cursors. Is there any way to close the cursors explicitly in 10.3.1?
    I am aware that when the iterator fetches the last result the cursor gets closed (in the case of any select query) but we have faced the same issue once/twice in the insert query also, is it because we have fired one insert after the other immediately? How much time does a cursor takes to close (implicitly) in the case of insertion of data?
    Thanks in advance..
    Edited by: GBP on Jan 5, 2011 4:07 AM

    Hi,
    Please see my post: Re: Cursor closing using DynamicSQL.executeQuery
    Hope this helps,
    Ariel

  • Invalid Cursor state Exception  -  Help required

    Hi,
    I'm having a web page(JSP), which is making use of 3 ResultSet objects. Using the first two, i'll populate two different Drop down list, with values from database(Access) while loading the page for first time.
    Now if the user select any value from any (or both) of drop down list and clicks submit, i need to display all values in database, meeting the criteria from first & second drop down list. For this selection, i'm using the third ResultSet variable. While executing the query, i'm sure that 3rd ResultSet is returning some value. But when i try to retrieve the value to a string variable, i'm getting the Invalid cursor state exception.
    Throughout the page, i haven't closed any of the ResultSet. When i closed the first and second ResultSets in the third function(where 3rd ResultSet is used), i'm not getting any value. Its returning like ResultSet closed.
    Please help me to get this solved. It's very urgent because without this, i cannot proceed further. Please share your ideas.
    Thanks in advace for your valuable help

    If you open a new resultset within the same statement, all previously opened will be closed.
    Read the API docs, luke.

  • Setting up web Bex in BWsystem:error com.sap.mw.jco.JCO$Exception:Issuer of

    Dear SAP Gurus,
    I'm facing an error when seting up web Bex in BW system which is based on AS java patch 14 when i run Diagnostics & Support Desk Tool as described in Note 937697  there is only one red signal which is BI Mastersystem
    the error is
    RFC connection using properties in Portal System Landscape to ABAP backend has failed. Reason:
    com.sap.mw.jco.JCO$Exception:Issuer of SSO ticket is not authorized
    thanks in advance
    Rgds
    George Varghese

    thanks Deepika ,unfortunately I posted this a Long back ,time limit was very less ,we were not in a situation to do more R&D on that,it will be a Waste of time ,what I did is that I uninstall ed SAP and installed again with latest available Patches and we were succeed
    thanks
    George Varghese

  • How to access oracle cursors using jdbc (expecting ur earliest reply)

    Hi All,
    can anyone help me out by giving me an idea or sample code in accessing the cursors that are defined in the oracle... i have to access those cursors using java... Thanks in advance for your reply and time....
    Ragu

    I have tried to follow the example from the URL link you provided.
    I'm using :
    - Oracle 8.1.6/8.1.7
    - JDK 1.3.1
    I've created:
    create or replace package types
    as
    type cursorType is ref cursor;
    end;
    create or replace function sp_ListEmp return types.cursortype
    as
    l_cursor types.cursorType;
    begin
    open l_cursor for
    select ename, empno
    from emp
    order by ename;
    return l_cursor;
    end;
    Then I have on my code the following:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    String conStatus = "":
    String driver_class = "oracle.jdbc.driver.OracleDriver";
    String connect_string = "jdbc:oracle:thin:@slackdog:1521:oracle8";
    String query = "begin :1 := sp_listEmp; end;";
    Connection conn;
    Class.forName(driver_class);
    conn = DriverManager.getConnection(connect_string, "scott", "tiger");
    try{
    conStatus = "before prepareCall, ";
    CallableStatement cstmt = conn.prepareCall(query);
    conStatus = conStatus + "before Register out, ";
    cstmt.registerOutParameter(1,OracleTypes.CURSOR);
    conStatus = conStatus + "before execute, ";
    cstmt.execute();
    conStatus = conStatus + "before getObject, ";
    ResultSet rset = (ResultSet)cstmt.getObject(1);
    while (rset.next ())
    System.out.println( rset.getString (1) );
    cstmt.close();
    } catch (Exception e) {
    conStatus = conStatus + e;
    System.out.println(conStatus);
    What happens is that I am able to successfully compile the code. But when I run the code, it displays:
    "before prepareCall, before Register out, SQLException: incompatible types = -10."
    What does that mean? Pls point out to me what I did wrong in my code.
    Thanks.

  • How can I have a single cursor using elements 9 with Windows 7?

    Currently the cursor on my screen is 3 small boxes in place of the single arrow.  I am using Photoshop Elements 9 With Windows 7.  I have loaded the patch files currently in the Adobe system without any success.

    Thank-you that solved the issue.
    In a message dated 4/20/2014 8:57:10 P.M. Eastern Daylight Time, 
    [email protected] writes:
    Re:  How can I have a single cursor using elements 9 with Windows 7? 
    created by Barbara B. (http://forums.adobe.com/people/Barbara+B.)  in 
    Photoshop Elements - View the full  discussion
    (http://forums.adobe.com/message/6315096#6315096)

  • How to create counter with charcteristic values  using exception aggregatio

    Dear Experts,
    Can some one help me on the below issue
    Requirement : Creating a counter with char ( accounting doucment number) in the query by using exception aggregation & summarize on totals with CKF.
    Note : i dont have any keyfigure called counter in my infoprovider
    Please let me know how to create it.
    I came to know  that  create  new  CKF  & FV with replacemtn path with IO(Account document number)  & use FV in CKF. is this true & works??
    Please let me know how i should  proceed ahead??
    Thanks
    Surendra

    I have resoloved by own
    By  createin zckf--> fv choosing replacement path with IO as reference and key.
    then excepetion aggreation chosen : counter for all detailed values & check the checkbox calucate after aggreagation.
    Thanks

  • MacBook Pro 17" Cursor and Trackpad Issues

    I'm a long time Mac user. I bought a new MBP 17" last December and I have had continual issues with the cursor and track pad. Issues like:
    1. Selection accuracy. I place the cursor on top of the link or text I want to select and it doesn't select. I move the cursor off the target a little and it works.
    2. Cursor "submarining". I move the cursor and it disappears for a bit then reappears. This happens all the time when I'm inputting data into forms.
    3. Bad "tactiles". Moving the cursor using the trackpad does not have the same tactile sensation of my older 15". It feels jumpier, not as smooth, not nearly as accurate.
    4. Cursor jitters. Sometimes the cursor will shake like it has the jitters.
    Anybody else experiencing this? Is it bad hardware? Bad OS. Or just bad juju?

    I have a workaround. I bought the Logitech VX Nano mouse and it works perfectly. Big difference using it and the trackpad. Seems to me that with the 17" at 1920 X 1200 resolution the trackpad doesn't have enough granularity to navigate that amount of territory. Is this a design/engineering flaw with the 17" in 1920x1200 resolution? Anyways this ***** - now I have to haul a mouse with me.

  • Issue while posting using goods issue for delivery type NL

    Hello Experts,
    I have created an outbound delivery for an intra-company transfer (within same company code) between two plants. The delivery type in NL (replinishment delivery)
    When i am trying to post the goods issue from supplying plant, I am getting following error
    "Account type K is not defined for document type WL".
    Delivery type NL should not be used to issue stock to vendor but I am not issuing it to any external vendor , issuing the stokc only to a receiving plant.
    Please help to understand why i am getting this error.
    Regards,
    Nish.

    Hi,
    If you are doing an STO Scenario, Check whether you have created the supplying plant as a vendor.
    The Vendor Account group should be plants.
    Also check whether you have given the plant in the vendor master Purchasing Data - Extras tab in the menu click on add purchasing data & check.
    If you haven't assigned this, do the same & create a fresh STO & check.
    Hope it will work.
    Thanks & Regards,

  • Custom cursor using image gets resized bigger

    I have created a custom cursor using the following code:
    ClassLoader cl = this.getClass().getClassLoader();     
    Toolkit tk = Toolkit.getDefaultToolkit();
    Image im = tk.getImage( cl.getResource("images/wallcursor.gif"));
    Cursor Custom_Cursor = tk.createCustomCursor(im,new Point(9,9),"Drawing wall");
    draftGrid.setCursor( Custom_Cursor );The cursor is loaded and it works, however - the image I use for the cursor is resized so it gets too big. Any clues on why this happens?
    btw; draftGrid is one of my own classes that extends JComponent.
    - bjorn

    Thanks for your replies guys.
    I tried your code KPSeal, and it works in resizing the cursor image back to its original size. However, a gray square of size 32,32 (which is returned by getBestCursorSize()) is shown round the cursor.
    Here is the updated code (yours hade some minor bugs)
    Image im = tk.getImage( cl.getResource("images/wallcursor.gif"));
    try {
           tracker.addImage(im, 0 );
           tracker.waitForID(0);
    } catch( InterruptedException ie ) {
           ie.printStackTrace();
    int w = im.getWidth(this);
    int h = im.getHeight(this);
    int pw = Toolkit.getDefaultToolkit().getBestCursorSize(w, h).width;
    int ph = Toolkit.getDefaultToolkit().getBestCursorSize(w, h).height;
    System.out.println("w="+w+", h="+h+" - pw="+pw+", ph="+ph);
    Image cim = createImage(pw, ph);
    cim.getGraphics().drawImage(im,0,0, this);                     
    Cursor Custom_Cursor = tk.createCustomCursor(cim,new Point(0,0),"Drawing wall");
    draftGrid.setCursor( Custom_Cursor );The System.out.println statement prints: w=18, h=13 - pw=32, ph=32
    If I try to do the createImage with w and h instead of pw and ph the same gray square (32,32) is created, and in addition the cursor's size is too big which was the probem to begin with ...
    - bjorn

  • How to find the list of Queries/Reports which are using Exceptional Aggregation in SAP BI?

    Hi All,
    We are interested to know how to find the list of Queries/ Reports which are using Exceptional aggregation in SAP BI.
    Please let us know is there any table's to check the list of reports using Exceptional Aggregation in SAP BI.

    Hi,
    Here you go..
    1) Go to table RSZCALC and get list of ELTUID where AGGREXC is not INITIAL and AGGRCHA is not initial; now you get only exception aggregation set based on some chars. Also you can further add STEPNR = 1 since your intention is just to get query name , not the calculation details; this will reduce number of entries to lookup and save DB time for next steps.
    Here you will get list of exception aggregation UUID numbers from which you can get properties from RSZELTDIR.
    2) Pass list of RSZCALC-ELTUID to table RSZELTXREF - TELTUID and get list of RSZELTXREF -SELTUID - this table stores query to it's elements maping kind.
    3) Now again pass RSZELTXREF - SELTUID into same table but into different field RSZELTZREF - TELTUID and get RSZELTXREF - SELTUID
    This step you get query reference sheet or column or query general UUID for next step.
    4) Pass list of RSZELTXREF - SELTUID into RSZELTDIR - ELTUID with DEFTP as 'REP'. Now you get list of query names in RSZELTDIR - MAPNAME and description in TXTLG.
    Note: you can also get the reference chars used for exception aggregation from RSZCALC - AGGRCHA field.
    Hope this helps.
    Please keep in mind, it might take more time depends on how many query elements you have in the system...
    Comments added for better DB performance by: Arun Thangaraj

  • Using xdofx issue in BIP

    Hi,
    using xdofx issue in BIP
    <?xdofx: if Status ='Open' then 'O' else if Status ='Closed' then 'C' else if Status ='Received' then 'R' else 'P' end if?>
    the above statment working fine for me.
    but when i add another if statement for another field i.e.
    <?xdofx: if System ='AA' then 'Auto Adjust' else if System ='BM' then 'Billing Method' else System end if?>
    then it always displaying P. I dont have any value or data for System. why it is printing P from the field Status? Cant we use xdofx many times in the report?
    Thanks,
    Anu

    I am sure there must be a limit (right? :) ).
    Why don't you just use one "IF" as at time in separate xdofx tags?
    Only one be valid anyways!.
    Regards
    Jorge
    p.s If this answers your question then please mark it as "Correct" or "Helpful"

  • How to use Exceptions for a function module

    Hi folks,
            I have created  a new function module.Its working fine, but i am not aware of using exceptions for a function module. I hav just declared an exception in the 'exception' tab. Could any body explain me how to use that in my FM source code....Thanks...

    Hi Shyam,
    Have a look at this,
    START-OF-SELECTION.
      gd_file = p_infile.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = gd_file
          has_field_separator     = 'X'  "file is TAB delimited
        TABLES
          data_tab                = it_record
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
        IF sy-subrc NE 0.
          write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
          skip.
        endif.
    Regards,
    Sai

  • Can we create cursor using the table created dynamically

    Dear all,
    Can we create the cursor using the table which is created dynamically using "Execute immediate" within the same procedure,
    or is there any way to call the table created dynamically ..
    please Do Help me in this
    thanks alot
    Edited by: khaja on Jan 18, 2009 10:57 AM

    Well, I don't think this approach is bad in any possible circumstances. It depends on the requirements we don't know. Yes, usually applications should not be designed in this way. But 'usually' does not mean 'never'. One possible case is described in Oracle's example Referencing Database Objects that Do Not Exist at Compilation. It's possible to assume that tables inv_01_2003, inv_04_2003, etc from the referenced topic What Is Dynamic SQL? are generated automatically by some job using dynamic create table stmt. If the OP has similar requirements tnen this approach is not bad. It may not be the best one but it at least is not so bad as you said.
    I believe that OPs know their requirements much better than me. This is why I always try to answer the exact question. If the approach is really ugly then I don't answer such questions at all.
    Regards,
    Dima
    Message was edited by:
    DimaCit

  • Returning Cursor using WITH

    Hi
    in my procedure there is a Parameter cursor, How can I to return cursor using WITH
    my cursor is P_cursor
      open p_curosr is
      with my_tab ( select .....  from.....)
      select columns01, columns02,....etc
       from  my_tab,
               others_tabs
       where .....did not work
    How can I to open cursor returning to Client side ?

    did not workwhat is an error?
    probably you forgot to put with my_table AS
    SQL> set serveroutput on;
    SQL>
    SQL> declare
    2   cursor p is
    3   with t as (select 1 num from dual union all
    select 2 from dual)
    4    select * from t;
    5   p1 p%rowtype;
    6   --
    7  begin
    8   open p;
    9    loop
    10      fetch p into p1;
    11      exit when p%notfound;
    12      dbms_output.put_line(p1.num);
    13     end loop;
    14   close p;
    15  end;
    16  /
    1
    2
    PL/SQL procedure successfully completed
    SQL>
    Thanks
    But I need to Open P_cursor without Fetch , P_cursor is is ref cursor passed like parameter
    procedure   my_proc (P_cursor out  out  Typedefined)
       Open P_cursor
        WITH mytable as ( select ......)
      no work

Maybe you are looking for

  • How can I delete a user group that my computer will not delete?

    I tried to remove a user group from my desktop following the procedures given. I could remove all but one user. This is the one I want to remove. How can I do this? I have 4 user groups. Why?, when ever I had trouble and called AppleCare they had me

  • JDeveloper and its IntegratedWeblogicServer configuration

    Hello When we create a new domain in Weblogic (not Integrated with JDeveloper) there are some default configurations for example there is a default JMS servers and some default configuration for JMS Module , JMS resources But in default domain of JDe

  • Lightroom 3 not printing

    I recently updated my Lightroom 2 with the new Lightroom 3.  Tonight for the first time I tried to print as I always did on Lightroom 2.  When I hit the print button, in the "layout" pop up: print setting, color management, paper adjustment, and prin

  • Retractable (3rd party?) headset for E51

    Hello, I've recently acquired an E51 and today I excitedly(!) received a package from Germany containing some HDC-10 headsets with their 2.5mm plugs. I connected one to the E51 and got the message "Enhancement not supported". For years I had an even

  • What is causing my problem?

    I had been having an overheating problem with my MacBook Pro 17". It took a while but I figured out that my NETserver had been turned on (not by me) and the CPU was running non-stop doing something (figuring it to be malware generatd) that was causin