Create Oracle procedure in pl

Source: Internet
Author: User

The following articles will teach you how to skillfully create and implement Oracle procedure and call Oracle procedure in pl/SQL, we first use the relevant Code to introduce the actual operation steps. The following describes the specific content. I hope you will learn more about it.

 
 
  1.  Create table  
  2. create table A  
  3. (  
  4. USERID NUMBER(38),  
  5. PWD VARCHAR2(30)  
  6. )  
  7. tablespace USERS  
  8. pctfree 10  
  9. initrans 1  
  10. maxtrans 255  
  11. storage  
  12. (  
  13. initial 64K  
  14. minextents 1  
  15. maxextents unlimited  
  16. );  

Create Oracle procedure

 
 
  1. create or replace procedure up_sel(cur_test out sys_refcursor)  
  2. is  
  3. begin  
  4. open cur_test for  
  5. select * from a;  
  6. end;  

Delete stored procedure

 
 
  1. drop procedure up_sel 

Submit

 
 
  1. commit 

Execute Oracle procedure in PL/SQL

 
 
  1. -// file>>new >>test window  
  2. begin  
  3. Call the procedure  
  4. up_sel(cur_test => :cur_test);  
  5. end;  

In variable, enter the defined cursor name cur_test.

In Type, enter the Cursor Type Cursor.

Click the... icon on the right of the Value to display the expected result.

Of course, you can also right-click the stored procedure and click TEST.

Stored Procedure for deleting data

 
 
  1. create or replace procedure up_del  
  2. (userid in varchar2)  
  3. is  
  4. begin  
  5. delete from a where USERID=userid;  
  6. end;  

Enter the value to be passed in the value.

Add data

 
 
  1. create or replace procedure up_add  
  2. (  
  3. userid in varchar2,  
  4. pwd in varchar2  
  5. )  
  6. is  
  7. begin  
  8. insert into a(USERID,PWD) values(userid,pwd);  
  9. commit;  
  10. end;  

Run

 
 
  1. declare  
  2. begin  
  3. up_add(11,'222');  
  4. end;   

The above content is a description of Oracle procedure, hoping to help you in this regard.

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.