Usage of int and out stored procedures in PL/SQL

Source: Internet
Author: User

[SQL] <strong> usage of int and out in PL/SQL stored procedures </strong> 1. Introduction to in and out (1) in procedures and functions, the difference between a process and a function is that a function can return a value without a return value. (2) but both the process and function can specify one or more output parameters through out. We can use the out parameter to return multiple values in the process and function. Two int and out use Example 1. create or replace procedure updateSal (emp_no in number, empsal out number) as emp_sal emp. sal % type; begin select sal into emp_sal from emp where empno = emp_no; update emp set sal = emp_sal * 1.1 where empno = emp_no; empsal: = emp_sal; -- assign values to automatically output end; SQL> set serveroutput on; SQL> declare 2 num number; 3 begin 4 updateSal (7369, num); 5 dbms_output.put_line (num); 6 end; 7/800 PL/SQL procedure successfully completed 2. use empno to query multiple values: create or replace procedure selectEmp (emp_no in number, ename out varchar2, job out varchar2, sal out number) is begin select ename, job, sal into ename, job, sal from emp where empno = emp_no; end selectEmp; test: SQL> declare 2 ename varchar2 (40); 3 job varchar2 (40); 4 sal number; 5 begin 6 selectEmp (7369, ename, job, sal); 7 dbms_output.put_line (ename | job | sal); 8 end; 9/SMITHCLERK800 3. use empno to query all attributes of an object. create or replace procedure selectemp1 (emp_no in number, emp_row out emp % rowtype) is begin select * into emp_row from emp where empno = emp_no; end selectemp1; test: SQL> set serveroutput on; SQL> declare 2 emp_row emp % rowtype; 3 begin 4 selectemp1 (7369, emp_row); 5 dbms_output.put_line (emp_row.ename); 6 end; 7/SMITH from Han Xiaoshuang's column

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.