Call Oracle procedure operations in pl/SQL

Source: Internet
Author: User

The following articles mainly describe how to create and call Oracle procedure in pl/SQL. This article describes the actual procedure of Oracle procedure through the actual operations of the relevant application code, the following is an introduction to the main content of the text. I hope you will have some gains.

 
 
  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 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 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.

If you create an Oracle procedure in pl/SQL and call it, 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 preceding content describes how to create and call Oracle procedure in pl/SQL. We hope this will help you in this regard.

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.