How open cursor statement works

hi,
OPEN CURSOR [WITH HOLD] dbcur FOR
  SELECT result
         FROM source
         [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
         [GROUP BY group] [HAVING group_cond]
         [ORDER BY sort_key].
i want to know what does open cursor statement do, how it works,  what does dbcur contain?

Hi,
dbcur is cursor name gn by u....
Its like select statement....u hav used for all entries right....so if der are 3 records in ur int table and corresponding 3 records ll be fetched in select-endselect query right.....
here in open cursor statement u don hav INTO(destination) right
so after opening cursor......
FETCH NEXT CURSOR dbcur into wa1.
FETCH NEXT CURSOR dbcur into wa2.
FETCH NEXT CURSOR dbcur into wa3.
wa1,wa2,wa3 ll have the 3 records....
close cursor.....................
Cheers,
jose.

Similar Messages

  • DBIF_RSQL_INVALID_RSQL in OPEN Cursor Statement

    Hi,
          I am getting DBIF_RSQL_INVALID_RSQL error with short text Error in RSQL module of database interface.
      Dump is pointing to the query " FETCH CURSOR".
    I have used following code in the logic:
    Some times only i am getting dump and some times it isworking fine can any body suggest me how to tune this code?
       OPEN CURSOR WITH HOLD s_cursor FOR
        SELECT aebeln bebelp b~zekkn
        bvgabe bgjahr bbelnr bbuzei bbewtp awaers
      FROM ekko AS a
           INNER JOIN ekbe AS b
      ON aebeln = bebeln
      WHERE ( b~bewtp = 'L'
      OR b~bewtp = 'Q' )
      AND a~ebeln IN l_r_ebeln
      AND b~belnr IN l_r_belnr.
      FETCH NEXT CURSOR s_cursor
                     APPENDING CORRESPONDING FIELDS
                     OF TABLE it_ekbe
                     PACKAGE SIZE s_s_if-maxsize.
    also please suggest me how to use for all enties with data packet size logic as in the above code?
    Thnaks & Regards,
    Vamsi

    Hi Vamsi,
    Please check Max's earlier response. You had mentioned that the problem occurs during debugging. Can you please elaborate if it only occurs during debugging or always? I'm not sure if the exception could be triggered due to implicit COMMIT as mentioned by Max. I know that SELECT-ENDSELECT during debugging can trigger a short dump due to implicit COMMIT, but I don't know if that applies also to OPEN CURSOR ... WITH HOLD (don't have a system to test this and also to check what exception is triggered during SELECT-ENDSELECT processing due to implicit COMMIT).
    For further analysis I'd recommend to carefully read the short dump and cross-check this against the system log and especially the trace file of the affected work process. As pointed out by Rob the most likely source for this exception are too many conditions in your WHERE statement. However, based on your response this doesn't seem to be the case, so by checking system log and the work process trace file you might get further information that points to more exotic causes (see e.g. OSS note [8312564|https://service.sap.com/sap/bc/bsp/spn/sapnotes/index2.htm?numm=1398802|Problems due to insufficient Nametab buffer]).
    Using the information from short dump, trace file and system log do some research in OSS for possible causes. Providing all the necessary information for forum users might be tough for the more exotic causes of this exception...
    Good luck, harald

  • How a update statement works internally in oracle

    Hi,
    I just wanted to know when a user issues a update (any DML) statement, what are all the steps involved?
    Like when user updated some statement, the modified block goes to the undo tablespace and new data will be stored in the user PGA and when user issues a commit statement.Does it delinked it from the uno tablespace and lgwr flushed the block to the redo logfile(does the lgwr also flushed the uncommited changes to the logfile as datafile stores the committed as well as uncomitted data).Can anybody suggest me how all the things work internally?

    Hi,
    Many of the people post across the same questions and lot of discussions carried out. You can you answer straight from Oracle Docs.
    Any how refer to the following below links
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:288016031632
    Update Statement-10G
    - Pavan kumar N

  • OPEN CURSOR STATEMENT

    wat is the correct syntax for open cursor?do anyone provide sample code for it?

    Hi,
    DATA: C1 TYPE CURSOR.
    OPEN CURSOR C1 FOR
         SELECT * FROM SFLIGHT WHERE CARRID = 'LH '.
    http://www.sapdb.org/7.4/htmhelp/7b/0bdea252d746429420007a69bd06c7/content.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/f5/cbbd9f39694aa1b76759b6c801b4a1/frameset.htm

  • How the check statement works in a a loop

    Hi gurus,
    assume itab has 5 records.
    Loop at itab.
      ctr = ctr + 1
      write: sy-tabix.
      check ctr = 3.
      delete itab
    endloop.
    options:
          1 2 3 4 
          1 2 4 5 
          1 2 3 4 5 
          1 2 3 3 4 
    the answer is 1 2 3 3 4.
    Pls give me the expalanation.

    Hi,
      Here is the explanation for ur logic.
    Initially ctr = 0.
    1st record of itab:   ctr becomes 1. and sy-tabix = 1.
                                  Check condition fails as ctr <> 3. so control goes back to starting of the loop.
    2nd record of itab : ctr = 2,  sy-tabix = 2.  once again condtion fails ctr <> 3. control goes back to the starting of the loop.
    3rd record of itab (3rd loop) : ctr = 3,  sy-tabix = 3.  Check condition satisfies ctr = 3. So itab record (3rd record) gets deleted. i.e., now 4th record will become as 3rd record.
    4th loop :  As 4th record replaced as 3rd record. the values will be as follows
                      ctr = 4, sy-tabix = 3. Check condition fails as ctr = 4, but not 3.
    Hence the result till 4th loop is :  1  2  3  3 
    For the next loop, result will be 1 2 3 3 4
    Hope it is clear.

  • How update statement works

    Hi all,
    can you guys help me in understanding how an update statement works in oracle...
    Thanks
    Rajesh

    i mean what happens in background in oracle server
    when i fire a update statement.The oracle server puts the old data (i.e before updation) into the RBS and then updates the rows with the new data.
    Regards
    Amit Raghuvanshi

  • Open cursor for internal table

    Hi folks,
    I have a tricky question concerning the cursor function and internal tables. First of all, it is not possible to create a view. Instead I've to use a function module for extracting some data to the BI system.
    Actually most of the time I work with SELECT (for outer joins) and internal tables. At the end I have a internal table and must open an cursor. As fact, I can't open a cursor for an internal table - only database tables are allowed.
    OPEN CURSOR WITH HOLD s_cursor FOR SELECT * FROM lt_temp.
    Does someone have a clue how to solve my problem? Obviously I have to use a db table for a open cursor statement but on the same way I have to use a internal table for all my previous SELECT-statements.
    Thanks in advance for your help.
    Regards,
    Mrcl

    Why don't you use EXEC and ENDEXEC
    Check this link
    http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm

  • Runtime Error - DBIF_RSQL_INVALID_RSQL - Too many OPEN CURSOR

    When I try to train a Decision Tree Model via an APD process in RSANWB, I get a runtime error when my model is configured with too many parameter fields or too many leaves (with 2 leaves it works, with more it fails).
    By searching SAP Notes I see that there are many references to this kind of runtime errors. But no note on occurences of it in RSANWB / RSDMWB .
    Any information on this anyone?
    Claudio Ciardelli
    Runtime Errors         DBIF_RSQL_INVALID_RSQL
    Date and Time          29.07.2005 16:19:21
    |ShrtText                                                                                |
    |    Error in RSQL module of database interface.                                                   |
    |What happened?                                                                                |
    |    Error in ABAP application program.                                                            |
    |                                                                                |
    |    The current ABAP program "SAPLRS_DME_DECISION_TREE_PRED" had to be terminated                 |
    |     because one of the                                                                           |
    |    statements could not be executed.                                                             |
    |                                                                                |
    |    This is probably due to an error in the ABAP program.                                         |
    |                                                                                |
    |Error analysis                                                                                |
    |    The system attempted to open a cursor for a SELECT or OPEN CURSOR                             |
    |    statement but all 16 cursors were already in use.                                             |
    |    The statement that failed accesses table "/BIC/0CDT000030 ".                                  |
    |    The erroneous statement accesses table "/BIC/0CDT000030 ".                                    |
    |Trigger Location of Runtime Error                                                                 |
    |    Program                                 SAPLRS_DME_DECISION_TREE_PRED                         |
    |    Include                                 LRS_DME_DECISION_TREE_PREDU06                         |
    |    Row                                     103                                                   |
    |    Module type                             (FUNCTION)                                            |
    |    Module Name                             RS_DME_DTP_EVALUATE                                   |
    |Source Code Extract                                                                               |
    |Line |SourceCde                                                                                |
    |   73|* Prepare for Data evaluation                                                               |
    |   74|  CATCH SYSTEM-EXCEPTIONS OTHERS = 15.                                                      |
    |   75|    CREATE DATA ref TYPE (i_enum_dbtab).                                                    |
    |   76|    ASSIGN ref->* TO <fs_wkarea>.                                                           |
    |   77|    ASSIGN COMPONENT gv_class_dbposit OF STRUCTURE                                          |
    |   78|                      <fs_wkarea> TO <fs_class>.                                            |
    |   79|    CREATE DATA ref TYPE TABLE OF (i_enum_dbtab).                                           |
    |   80|    ASSIGN ref->* TO <ft_data>.                                                             |
    |   81|                                                                                |
    |   82|  ENDCATCH.                                                                                |
    |   83|  IF sy-subrc = 15.                                                                         |
    |   84|*   Error on Assignment.                                                                    |
    |   85|    CALL FUNCTION 'RS_DME_COM_ADDMSG_NOLOG'                                                 |
    |   86|      EXPORTING                                                                             |
    |   87|        i_type    = 'E'                                                                     |
    |   88|        i_msgno   = 301                                                                     |
    |   89|        i_msgv1   = 'EVALUATION_PHASE'                                                      |
    |   90|      IMPORTING                                                                             |
    |   91|        es_return = ls_return.                                                              |
    |   92|    APPEND ls_return TO e_t_return.                                                         |
    |   93|    EXIT.                                                                                |
    |   94|  ENDIF.                                                                                |
    |   95|                                                                                |
    |   96|* For the un-trained Rec-Ids, evaluate.....                                                 |
    |   97|  REFRESH lt_recinp.                                                                        |
    |   98|  APPEND LINES OF i_t_records TO lt_recinp.                                                 |
    |   99|  SORT lt_recinp .                                                                          |
    |  100|* Open Cursor..                                                                             |
    |  101|  DATA: l_curs TYPE cursor.                                                                 |
    |  102|  DATA: l_psize TYPE i VALUE 10000.                                                         |
    |>>>>>|  OPEN CURSOR WITH HOLD l_curs FOR                                                          |
    |  104|   SELECT * FROM (i_enum_dbtab)                                                             |
    |  105|     WHERE rsdmdt_recid NOT IN                                                              |
    |  106|        ( SELECT rsdmdt_recid FROM                                                          |
    |  107|             (i_learn_tab) ).                                                               |
    |  108|                                                                                |
    |  109|*  Start Fetch...                                                                           |
    |  110|  DO.                                                                                |
    |  111|    FETCH NEXT CURSOR l_curs                                                                |
    |  112|      INTO CORRESPONDING FIELDS OF TABLE <ft_data>                                          |
    |  113|      PACKAGE SIZE l_psize.                                                                 |
    |  114|    IF sy-subrc NE space.                                                                   |
    |  115|      EXIT.                                                                                |
    |  116|    ENDIF.                                                                                |
    |  117|                                                                                |
    |  118|*     Process records...                                                                    |
    |  119|    LOOP AT <ft_data> ASSIGNING <fs_wkarea>.                                                |
    |  120|                                                                                |
    |  121|*     Call Prediction Function.                                                             |
    |  122|      CALL FUNCTION 'RS_DME_DTP_PREDICT_STRUCTURE'                                          |

    Hi Claudio,
    well the message is very clear and I think in your case you need to split your model into a few somehow equal models, each not having more than 2 leaves.
    Another option might be to do more things serially instead of parallel.
    Hope it helps
    regards
    Siggi

  • Opened cursors

    Hello everybody,
    i need the number of opened database cursors (with the OPEN CURSOR statement) in an Abap process (programm). Does anyone know if i can get the number in Abap in runtime??
    For example something like the VBLOG table cluster.
    Regards Ioan.

    Hi , Please go throuw below info and example.
    << Moderator message - Cut and paste response from [Using a Cursor to Read Data|http://help.sap.com/SAPhelp_nw04/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm] removed. Plagiarism is not allowed in SCN >>
    Edited by: Rob Burbank on Feb 2, 2011 11:44 AM

  • OPEN dataset statement

    Hi folks,
    I have a file stored on the network shared drive. Can I read the file using open dataset statement. This file is not stored on the application server.
    I have read that the open dataset statement works for only with the files stored in the application server.
    thanks
    sankar

    Hi
    Go thru this code, it will help you,.
    See the use of open dataset statement here.
    Pls reward if help.
    Refer this:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
    *& Report  ZUPLOADTAB                                                  *                     &----
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    DATA: ld_file LIKE rlgrap-filename.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 like pa0002-VORNA,
        name2 like pa0002-name2,
        age   type i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Text version of data table
    TYPES: begin of t_uploadtxt,
      name1(10) type c,
      name2(15) type c,
      age(5)  type c,
    end of t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) type c.
    constants: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *START-OF-SELECTION
    START-OF-SELECTION.
    ld_file = p_infile.
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    ELSE.
      DO.
        CLEAR: wa_string, wa_uploadtxt.
        READ DATASET ld_file INTO wa_string.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                          wa_uploadtxt-name2
                                          wa_uploadtxt-age.
          MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
          APPEND wa_upload TO it_record.
        ENDIF.
      ENDDO.
      CLOSE DATASET ld_file.
    ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    Display report data for illustration purposes
      loop at it_record into wa_record.
        write:/     sy-vline,
               (10) wa_record-name1, sy-vline,
               (10) wa_record-name2, sy-vline,
               (10) wa_record-age, sy-vline.
      endloop.

  • Update statement  works in oracle RAC

    Hi Experts,
    How the update statement works in oracle RAC environment.
    And why we need a separate redo for each instance what will happen if we wont give.
    Regrds
    Suneel

    user1175505 wrote:
    Hi Experts,
    How the update statement works in oracle RAC environment.UPDATE does not know or care if it on RAC or single instance.
    And why we need a separate redo for each instance what will happen if we wont give.you can't start Oracle DB without any REDO.
    Handle:     user1175505
    Status Level:     Newbie
    Registered:     Jun 9, 2010
    Total Posts:     610
    Total Questions:     249 (182 unresolved)
    WOW! Why do you waste your time here when you rarely get answers to your questions?

  • 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 get highest number of open cursors within the current calendar day

    Hi all ,
    i need to know how to get the highest number of open cursors within the current calendar day.
    Thanks ,

    823030 wrote:
    the issue is my customer is getting the error ORA-01000: maximum open cursors exceeded and we need an sql statment that gets the following values :
    -highest number of open cursors experienced in the current calendar day.
    -current open cursors
    -and maximum open cursorsThis error is rare. It happens when
    a) the value of the open cursor parameter is set extremly low (default is something like 1000). Low would be something like 10.
    b) <strike>you have many concurrent users(=sessions) and </strike>the application does not use bind values
    In this case each select will open a new cursor, instead of reusing it.
    c) you have a select that opens a cursor for each line. This can happen with a statement where you have the CURSOR keyword somewhere in the select or where clause. Those cursors will be closed when the select is finished. But during the run time of the select, all cursors stay open.
    To track the number of "open cursors" during the day you would need to implement some monitoring. Maybe based on the view that was already mentioned.
    Edited by: Sven W. on May 16, 2011 2:30 PM - since the parameter is on session level, other open cursors should not influence it much.

  • How to close open cursors in a forms app

    All,
    I'm not a forms developer. I'm a database administrator so I'm asking this question from that perspective. I know nothing about forms development.
    We have several forms applications that appear to hold many SELECT cursors open when they run. I've asked my forms developers about this and they are giving me the idea that they don't have much control over this. I have no idea myself so I'm asking here.
    When one issues selects from a form, do those selects remain as open cursors while the form runs? Is it possible to close those select cursors from within the form so that the application does not keep so many cursors open simultaneously?
    I am typically seeing a forms application with 70-100 open cursors. And we have hundreds of end users each running the forms application which is causing a lot of problems with the sheer number of open cursors.
    I've already bumped the database OPEN_CURSORS parameter but it's my feeling that developers should be doing a better job of closing cursors from within the form.
    Can anyone give me some guidance here or point me to some documents that describe how to reduce the number of open cursors to the database from a forms app?
    Thanks,

    There are several ways Forms use cursors. In the standard default method, users enter a query where condition and then execute the query. This process opens a cursor on the server, and the form fetches a few (20 or so) rows and displays on the screen (in a base-table "block"). If the user scrolls down, more rows are fetched from the cursor. This can go on and on if the user keeps scrolling down through the data. I am not sure when the cursor gets closed -- there is no Forms command to close this one. Only closing the form, or else re-executing the query process would close such a cursor.
    In the PL/SQL code, where the developer has control, a cursor can be opened, rows fetched, and then closed. This can be done either with Open-Fetch-Close or in a For... Loop. The developer can explicitly close this cursor, or PL/SQL theoretically closes the cursor when the block of code is exited.
    There is of course the SQL Select into, but that only works in PL/SQL for single-row selects. I doubt this is a major problem.
    And finally, there are the record groups, where Forms runs the select to draw all the data into an array in the form. These should be closed automatically, I believe.
    Now... if you can determine which tables the cursors are remaining open, maybe your developers can zero in on the forms, and maybe clean up some things. However, I am doubtful much can be done. It seems to me that if the open cursors are causing some database sluggishness, then maybe adding more memory on the server is the best option.

  • 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

  • Dynamic creation of class objects?

    I have a requirement where in at runtime I would know the class name, method name, properties, interface..and coding lines to be put into a method? Can anyone suggest a way to create the consumable central class object with these details, activate it

  • Will not boot after reload of OS

    Ok, so here is my tale of trouble.  I have a Lenovo T61 Type 6463-5BU, S/N L3-xxxxx.  The hard drive died a couple of weeks ago, and I have since then received a replacement drive under warranty, i.e. the exact same type of drive.  We had a backup im

  • SAP PI: Using Variable Header  Binding in Receiver Mail Adapter

    Hello, I try to use Variable Header Bindings in the Receiver Mail Adapter. Therefore I wrote the following User-Defined-Function in a mapping: Java Function Start - DynamicConfiguration conf = (DynamicConfiguration) container     .getTransformationPa

  • I need information about basic features before deciding to upgrade

    There is very little information on basic iPhoto 11 specifications. Can I upload AVCHD Lite video clips, and will they automatically work in iMovie (like motion JPEG ones do)? Can I easily create and switch among multiple libraries? How will iMovie r

  • Corresponding R/3 table.

    Hi All, I have a R/3 Quantity field thats populating another quantity field in BW. I think its getting the wrong numbers. How can go back to R/3 to check if the numbers match. I have the technical name of the R/3 field but not sure in which table its