PL/SQL Practice cursor cursor:oracle A private area of memory allocated for SQL statements when executing SQL statements

Source: Internet
Author: User

Implicit cursors: You can only return one row of results at a time (no definition, default auto-build)
Span style= "Font-family:courier new, Courier; FONT-SIZE:16PX ">  explicit cursor: Requires a developer to define in advance, you can loop through the SQL statements in the cursor, return multiple rows of results
 
  Properties of an implicit cursor:
   sql%rowcout     statistics The number of records processed in a cursor
   sql%found      If a record matching the criteria can be found in the cursor, the result is true
   sql%notfound   if a record that matches the condition can be found in the cursor, the result is true
   sql%isopen     determines whether a cursor is open, and the default cursor in an implicit cursor automatically opens

1. An implicit cursor:

Sql%NotFound If a record that matches a condition can not be found in the cursor, the result is true SQL> Declare  2    3v_id t1.id%type; 4    5  begin  6    7V_ID:=Ten; 8    9    UpdateT1SetId= - whereId=v_id;Ten    ifSql%NotFound Then  One    Insert  intoT1 (ID)Values(v_id); A    Commit;  -    End if;  -  End;

2. Sql%found if a record matching the criteria can be found in the cursor, the result is true

Sql> Declare  2    3v_id t1.id%type; 4    5  begin  6    7V_ID:=Ten; 8    9    Delete  fromT1whereId=v_id;Ten    One    ifSql%Found Then  ADbms_output.put_line ('T1 Recorder is delete!');  -    Commit;  -    End if;  the  End;

3.sql%rowcout statistics The number of records processed in the cursor

Sql> Declare  2    3v_id t1.id%type; 4    5  begin  6    7V_ID:=Ten; 8    9    Insert  intoT1 (ID)Values(v_id);Ten    Delete  fromT1whereId=v_id; One    A    ifSql%Found Then  -Dbms_output.put_line ('T1 Recorder is delete!');  -Dbms_output.put_line ('T1 Recorders'||Sql%RowCount||'rows was deleted!');//Count the number of deleted rows the    Commit;  -    End if;  -  End;


PL/SQL Practice cursor cursor:oracle A private area of memory allocated for SQL statements when executing SQL statements

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.