"ORACLE" plsql Create stored procedure (11g)

Source: Internet
Author: User
Tags dname

Stored procedures with no parameters

sql> Create or replace procedure Get_time is
2 begin
3 Dbms_output.put_line (sysdate);
4 End;
5/

Procedure created.

sql> exec get_time;

15-may-17

PL/SQL procedure successfully completed.

Stored procedure with in parameter

sql> Create or Replace procedure Add_dept
2 (v_dept_id in number, v_dept_name in varchar2) is
3 begin
4 INSERT INTO Dept (DEPTNO, Dname)
5 values (v_dept_id,v_dept_name);
6 dbms_output.put_line (' Inserted ' | | Sql%rowcount | | ' Row ');
7 End;
8/

Procedure created.

sql> var s1 number
sql> var s2 varchar2
Sql> EXEC:S1: =60

PL/SQL procedure successfully completed.

sql> exec:s2: = ' sss '

PL/SQL procedure successfully completed.

Sql> exec add_dept (: S1,:S2);
Inserted 1 row

PL/SQL procedure successfully completed.

sql> print S1 s2;

S1
----------
60


S2
--------------------------------
Sss

Sql> Select Deptno, dname from dept;

DEPTNO dname
---------- --------------
Ten ACCOUNTING
About
SALES
OPERATIONS
Sam
SSs

Stored procedures with in and out parameters

sql> Create or replace procedure compute
2 (Num1 in out number,num2 on out number)
3 is
4 v1 number;
5 v2 number;
6 begin
7 v1: = num1/num2;
8 V2: = mod (num1,num2);
9 NUM1: = v1;
Ten num2: = v2;
one end;
12/

Procedure created.

"ORACLE" plsql Create stored procedure (11g)

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.