Oracle implicit cursor small example

Source: Internet
Author: User

1: difference between implicit cursor and display cursor

* No need to declare a cursor

* No need to open or close the cursor

* The INTO clause must be used. Only one INTO clause can be returned.

 


2: Similarities between an implicit cursor and a display cursor

Same attributes

 


3: Small Example

DECLARE

Name VARCHAR2 (50 );

Department_name varchar (20 );

BEGIN

SELECT name, department_name

INTO name, department_name

FROM employees e, departments d

WHERE e. department_id = d. department_id and e. id = 1;

Dbms_output.put_line (name | 'in' | department_name );

END;

 


4: Implicit cursors use attributes

Syntax:

SQL % isopen SQL % found SQL % NOTFOUND

SQL % ROWCOUNT -- usually used to determine whether insertion, update, and deletion are successful, but before the COMMIT statement

Attribute use instance:

BEGIN

UPDATE employees SET name = name | 'A' WHERE id = 7;

If SQL % ROWCOUNT = 1 THEN -- SQL % FOUNF can also

DBMS_OUTPUT.PUT_LINE ('table updated ');

ELSE

DBMS_OUTPUT.PUT_LINE ('No. Not found ');

End if;

END;

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.