Use of PL/SQL records

Source: Internet
Author: User


In PL/SQL, % ROWTYPE can be used as the row TYPE of a table, and % TYPE can be used as a field as the data TYPE, but several fields to be specified must be used as a data TYPE, you can use PL/SQL records. Definition Syntax of PL/SQL records: SQL code TYPE type_name is RECORD (filed_declaration [, filed_declaration ,... www.2cto.com filed_declaration]); identifier type_name uses PL/SQL record: SQL code declare -- defines TYPE nemp_record_type IS RECORD (nno scott. emp. empno % TYPE, nname scott. emp. ename % TYPE, ndept scott. dept % ROWTYPE); nemp_record nemp_record_type; eno number: = 7788; begin www.2cto.com -- assigns the query result to the defined nemp_record. If dept. * If values are assigned together, too many columns are allowed. empno, e. ename into nemp_record.nno, nemp_record.nname from scott. emp e, scott. dept d WHERE e. deptno = d. deptno AND e. empno = eno; SELECT * into nemp_record.ndept from scott. dept where deptno = (select deptno from scott. emp where empno = eno); dbms_output.put_line (nemp_record.ndept.dname); -- output: RESEARCH end; from Ear's blog

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.