Examples of Oracle's reference and record-based variable programs

Source: Internet
Author: User

--Reference variable--open Oracle output--set serveroutput ondeclare    -Define reference variable, query and print 1232 name and salary    --pename varchar2 (20);-- These 2 sentences and the following 2 sentence effect consistent    --psal number;    Pename Emp.ename%type;    Psal emp.sal%type;begin    --get 1232 of the name and salary-    -the way to assign the value is: = and into    select Ename,sal to pename,psal from EMP where empno=122;        --Print name and salary    dbms_output.put_line (pename| | ' The salary is ' | | PSAL);        end;/    

Example of a record-type variable program:

--Record type variable: Take the type of a row in a table as the type of the variable--you can interpret the record variable as an array, and each element in the array represents each column--REC is the shorthand for the record, row is the row, type is the kind, and the row type--Emp_rec emp% rowtype;--the reference of the variable component of record type--emp_rec.ename:= ' ADAMS ';  --Use record variables to query and print 123 of the name and salary--set Serveroutput on declare     --Define the record type variable: note represents a row     Emp_rec emp%rowtype; begin    -- Get 1231 lines of information        select * into Emp_rec from EMP where empno=123;        --Print name and salary    dbms_output.put_line (emp_rec.ename| | ' The salary is ' | | Emp_rec.sal);   End;   --/


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Examples of Oracle's reference and record-based variable programs

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.