tailieunhanh - HandBooks Professional Java-C-Scrip-SQL part 173

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 173', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Records in PL SQL A PL SQL record is a data structure composed of multiple pieces of information called fields. To use a record you must first define it and declare a variable of this type. There are three types of records table-based cursor-based and programmer-defined. Declaring Records You define and declare records either in the declaration section of a PL SQL block or globally via a package specification. You do not have to explicitly define table-based or cursor-based records as they are implicitly defined with the same structure as a table or a cursor. Variables of these types are declared via the ROWTYPE attribute. The record s fields correspond to the table s columns or the columns in the SELECT list. For example DECLARE -- Declare table-based record for company table. comp_rec company ROWTYPE CURSOR comp_summary_cur IS SELECT SUM gross FROM company C sales S WHERE -- Declare a cursor-based record. comp_summary_rec comp_summary_cur ROWTYPE Programmer-defined records must be explicitly defined with the TYPE statement in the PL SQL declaration section or in a package specification. Variables of this type can then be declared as shown here DECLARE TYPE name_rectype IS RECORD prefix VARCHAR2 15 first_name VARCHAR2 30 middle_name VARCHAR2 30 sur_name VARCHAR2 30 suffix VARCHAR2 10 TYPE employee_rectype IS RECORD emp_id NUMBER 10 NOT NULL mgr_id NUMBER 10 dept_no TYPE title VARCHAR2 20 name empname_rectype hire_date DATE SYSDATE fresh_out BOOLEAN -- Declare a variable of this type. new_emp_rec employee_rectype BEGIN Referencing Fields of Records Individual fields are referenced via dot notation record_namefield_name For example employee. first_name Individual fields within a record can be read from or written to. They can appear on either the left or right side of the assignment operator BEGIN insurance_start_date 30 FALSE . .

TÀI LIỆU LIÊN QUAN
10    158    1
6    184    1
7    162    1
5    157    1
6    160    1
6    152    1
6    150    1
6    206    1
7    154    1