Oracle PL/SQL tables, record types

Source: Internet
Author: User

I. PL/SQL table
The PL/SQL table has only two columns, where the first column is listed as an integer type and the second column is the user custom.
Defined:
TYPE < type name > is TABLE of Types of < columns > [Not NULL] INDEX by Binary_integer;
The type of < column > can be a data class row for Oracle and a user-defined type.

Property Method:
. Count-Returns the total number of rows in a PL/SQL table
. delect--Delete all the contents of the PL/SQL table
. Delect (number of rows)--delete the specified row of the PL/SQL table
. DELCT (start line, end line)--delete multiple rows of the PL/SQL table
. First-Returns the initial index of a table;
. Next (number of rows)-the index of the next bar of this line number;
. Last-Returns the final index of the table;



Ii. PL/SQL Records
The PL/SQL table has only one row, but there are multiple columns.
Defined:
 TYPE < type name > is RECORD < column name 1 type 1, column name 2 type 2,... Column name N type n,> [not NULL]
The type of < column > can be a data class row for Oracle and a user-defined type, and can be a nesting of record types.



Iii. combined use of PL/SQL tables and PL/C records
Example:

DECLARE CURSOR c_1 is SelectEmpno,ename,job,sal fromEMP; TYPE myrecord is RECORD (Empno emp.empno%type,ename emp.ename%type,job emp.job%type,sal Emp.sal%type);--Define a myrecoed named pl/SQL record type; TYPE mytable is TABLE of Myrecord    index by Binary_integer; --Defines a PL/SQL table type named mytable; the field type is pl/SQL record type; n Number:=1; tab_1                     mytable; --instantiate a Tab_1 object for the mytable type; BEGIN--Assign Value forIinchc_1 Loop tab_1 (n). Empno:=I.empno; Tab_1 (n). ename:=I.ename; Tab_1 (N). Job:=I.job; Tab_1 (n). Sal:=i.sal; N:=n+1;       End Loop; N:=1; --Output forIinchN.. Tab_1.count Loop Dbms_output.put_line (i||' '|| Tab_1 (i). empno| |' '|| Tab_1 (i). ename| |' '|| Tab_1 (i). job| |' '||tab_1 (i). Sal); End Loop; END; 



Oracle PL/SQL tables, record types

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.