Oracle cursor: Query and print employee name and salary

Source: Internet
Author: User
Tags oracle cursor

Oracle cursor: Query and print employee name and salary

-- Query and print employee name and salary -- set serveroutput on/* 1. cursor attribute % found: true if the record is obtained; otherwise false; % notfound: */declare -- Define a cursor cemp is select ename, sal from emp; -- Define the corresponding variable pename emp for the cursor. ename % type; psal emp. sal % type; begin -- open the cursor open cemp; loop -- take the order behind the record into and define the ename behind the cursor. sal has the same order as fetch cemp into pename and psal; -- think: 1. When does the loop exit? 2. fetch may not necessarily get the record -- exit when does not get the record exit when cemp % notfound; -- print the obtained record dbms_output.put_line (pename | 'salary is '| psal ); end loop; -- close the cursor to close cemp; end ;/

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.