Oracle Stored Procedure Syntax

Source: Internet
Author: User

1. Basic structure CREATE OR REPLACE PROCEDURE stored procedure name (parameter 1 in number, parameter 2 in number) is variable 1 INTEGER: = 0; Variable 2 DATE; The BEGIN end stored procedure name 2.SELECT into STATEMENT stores the results of a SELECT query into a variable, can store multiple columns simultaneously in multiple variables, must have a record, or else throw an exception (if no record throws No_data_found) Example: BEGIN SELECT col1,col2 into variable 1, variable 2 from typestruct where xxx; EXCEPTION when No_data_found THEN xxxx; End; ... 3.IF to determine IF v_test=1 THEN BEGIN do something end; End IF; 4.while Loop while V_test=1 loop BEGIN XXXX end; End LOOP; 5. Variable assignment value v_test: = 123; 6. Use for cursor ... is CURSOR cur are SELECT * from XXX; Begin for Cur_result in cur LOOP begin v_sum: =cur_result. Column name 1+cur_result. Column Name 2 end; End LOOP; End; 7. CURSOR CURSOR C_user (c_id number) is SELECT NAME from USER WHERE typeid=c_id with parameters; OPEN c_user (variable value); LOOP FETCH c_user into V_name; EXIT FETCH C_user%notfound; Do something end LOOP; Close C_user; 8. Use PL/SQL Developer Debug Connect the database to create a test window in the window to enter the calling SP code, F9 start debug,ctrl+n step debugging This article is from the original PHP Information link: http:// Www.phpq.net/oracle/oracle-stored-procedure-syntax.html

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.