Submitted to the database after the cursor to the value problem

2010-12-20  来源:本站原创  分类:Database  人气:76 

Submitted to the database, the cursor can then value.

Experiments are as follows:

CUSTOMER table:

CUSTOMERID NAME LOCATION
---------- -------------------- --------------------
201 Dennis Haidian
202 John Chaoyang
203 Tom East
204 Jenny East
205 Rick West

Stored procedure:

create or replace procedure Hello is
        cur_result customer%rowtype;
        i number;
        cursor cur_select is select CUSTOMERID,NAME,LOCATION from customer;
    begin
        i := 0;
        open cur_select;
        dbms_output.put_line(' Start ');

    -- First time through the loop value
    loop
        i := i + 1;
        fetch cur_select into cur_result;
        if cur_select%notfound then
            dbms_output.put_line('exit  The first value ');
            exit;
        end if;
        dbms_output.put_line(' The first time '||i||'='||cur_result.name);
        if i = 2 then
            dbms_output.put_line(' First commit '||i||'='||cur_result.name);
            commit;
            exit;
        end if;
    end loop;

    -- Second cycle value
    loop
        i := i + 1;
        fetch cur_select into cur_result;
        if cur_select%notfound then
            dbms_output.put_line('exit  The second value '');
            exit;
        end if;
        dbms_output.put_line(' The second '||i||'='||cur_result.name);
    end loop;
    close cur_select;
end Hello;
/

********************************************

The results are as follows:

Started the first 1 = Dennis
The first 2 = John
First submitted 2 = John
Second 3 = Tom
Second 4 = Jenny
Second 5 = Rick
exit value of the second

********************************************

Evidence submitted to the database, did not close the cursor, without having to open and continue to value

相关文章
  • Submitted to the database after the cursor to the value problem 2010-12-20

    Submitted to the database, the cursor can then value. Experiments are as follows: CUSTOMER table: CUSTOMERID NAME LOCATION ---------- -------------------- -------------------- 201 Dennis Haidian 202 John Chaoyang 203 Tom East 204 Jenny East 205 Rick

  • displaytag paging method of the database and export data deal with the problem 2010-04-06

    displaytag Database Paging method and deal with the problem of data derived Articles Category: Java Programming Recently with the use of springside struts2 + spring2.5 + hibernate3 a project, in order not to reinvent the wheel (in fact, lazy, and the

  • Oracle 10g database using the cursor 2010-11-17

    - Use the cursor 1) 9i to use before, once to take a data - 1, shows the cursor declare -- Define a cursor cursor temp_cursor is select t.name,t.english_name from communitytype t; --where t.community_type_id = 'ebook'; -- Define variables v_name comm

  • Exception handling database stored procedure cursor 2011-04-11

    oracle Study Notes (e) of the cursor 1. Cursors: SQL memory area designated private reference to this memory area to save the SQL statement execution results. In PL / SQL block, without using cursors, Select statement only returns one record. Each Or

  • DataGrid ComboBox modify data within the Union and submitted to the database 2010-02-24

    Click the DataGrid cell editing appears ComboBox, select the appropriate value, to make the data written to the database should call the itemEditEnd DataGrid event, itemEditEnd incident after leaving the cell editing is triggered. itemEditEnd event m

  • (Turn) ibatis to use mysql, database, time-out automatically closed solution to the problem 2010-03-29

    iBatis to bring their own, a simple database connection pool, the basic function of both. However, in dealing with part of the database (eg mysql) the connection idle for too long (mysql is 8 hours) when the automatic time-out, they compare as the c3

  • SQL Server database password associated sa solution to the problem 2010-03-09

    Query Analyzer, connect, authenticate using the "use windows authentication" Then, run: EXEC sp_password NULL, 'NewPassword', 'Sa' Enterprise Manager -> Instance Name -> Security -> Login -> Double-click to the right of SA -> Chan

  • mysql database name and table name case sensitivity problem 2010-04-02

    In MySQL, databases and tables correspond to those directory of directories and files. Thus, the operating system, database and determine the sensitivity of the case sensitive table name. This means database and table names in Windows is not case sen

  • Database link that contains a special character problem 2010-07-01

    If we connect the data when some of the special characters that contains the user name or password put directly added to the URL above, then the database will recognize this user name does not come out or will be considered as the user name password

  • ORA-01092 database not open the cause of the problem 2010-11-10

    Oracle10.2.0.1 to 10.2.0.4 upgrade, the upgrade is complete, even when connecting to the database ORA-01092 failure occurred, leading to not open the database, the phenomenon is as follows: SQL> startup ORACLE instance started. Total System Global Ar

  • MySQL database connection timeout (wait_timeout) deal with the problem 2010-12-21

    refer to: http://sarin.javaeye.com/blog/580311 Surely we will encounter when in use MySQL connection timeout problem, as shown below: Is the exception (com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet s

  • ORA-01092 database not open the cause of the problem (the problem is not successful database upgrade) 2010-11-10

    Oracle10.2.0.1 to 10.2.0.4 upgrade, the upgrade is complete, even when connecting to the database ORA-01092 failure occurred, leading to not open the database, the phenomenon is as follows: SQL> startup ORACLE instance started. Total System Global Ar

  • Cursor by querying the database was populated listview problems 2010-05-08

    1, obtained by querying a database filled listView Cursor section must qurey the projection of _id of this column contains the table, otherwise error of. Why does this column? We believe that, when filled, will listView Item with each table correspon

  • Cursor can spread through database links 2011-03-14

    In dealing with the page query, frequently used method is the database server to open a cursor on a stored procedure, then the cursor will return to the page directly handling procedures. Colleagues in dealing with today, when the cursor to ask a que

  • JDBC technology and database connection pooling feature (reprint) 2009-10-02

    JDBC Basics First, access the database using JDBC basic steps: A. loading JDBC driver B. definition connection URL C. establish a connection D. create a Statement object E. execute a query or update F. The results dealing with G. Close the connection

  • (Transfer) the reasons for slow database query 2010-02-04

    ● query slow for many reasons, common following categories: 1, no index or index is not used (this is the most common problems slow query is programming defects) 2, I / O throughput is small, the formation of a bottleneck effect. 3, does not create a

  • 50 Ways to clever optimization of SQL Server database 2010-08-17

    Query slow for many reasons, common following categories: 1, no index or index is not used (this is the most common problems slow query is programming defects) 2, I / O throughput is small, the formation of a bottleneck effect. 3, does not create a c

  • The reasons for slow database query 2010-09-20

    Query slow for many reasons, common following categories: 1, no index or index is not used (this is the most common problems slow query is programming defects) 2, I / O throughput is small, the formation of a bottleneck effect. 3, does not create a c

  • Sum up the work in the Sybase database (6) 2010-04-08

    Some exceptions and on the common approach 1. The following statement is used to handle the log full of Sybase data when (The transaction log in database EBILLS is almost full. Your transaction is being suspended until space is made available in the

  • Specify the database column specified id query 2010-04-30

    Simple database query 1. Cursor by target database, such as: Contacts Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null); 2. Query the database to specify the data column id specified public String getValueByColumnId(Cu