The PL/SQL block for Oracle Learning

Source: Internet
Author: User

1. Start simple

DECLARE
Name VARCHAR2 (20);
BEGIN
Select First_Name into name from Hr.employees where employee_id=&no;
Dbms_output.put_line (name);
EXCEPTION
When No_data_found Then
Dbms_output.put_line (' The employee does not exist! ');
END;
/

2. Simple---

DECLARE
TYPE Emp_record_type is record (
Name Emp.ename%type,
Salary Emp.sal%type
);
TYPE Ename_table_type is table of Emp_record_type;
Ename_table Ename_table_type;
BEGIN
SELECT ename,sal BULK COLLECT to ename_table from EMP;
For I in 1..ename_table. COUNT LOOP
--dbms_output.put_line (Ename_table (i). Name);
Dbms_output.put (Rpad (ename_table (i). name,20, "));
Dbms_output.put_line (Rpad (ename_table (i). salary,10, "));
END LOOP;
END;
/

The PL/SQL block for Oracle Learning

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.