Create and debug ORACLE stored procedures

Source: Internet
Author: User

1. stored procedures are a good technique.

2. PSD (PL/SQL Developer) is a good tool that can greatly improve efficiency.

3. Use PSD to connect to the database and start creating the stored procedure:

Create or replace procedure Test_ADD2 (VAR_NAME in VARCHAR2, VAR_SEX out VARCHAR2) is
Begin
IF VAR_NAME = 'yuer' THEN
VAR_SEX: = 'male ';
ELSE
VAR_SEX: = 'female ';
End if;
End Test_ADD2;
Create or replace procedure indicates re-creation when the stored procedure exists, VAR_NAME indicates the parameter name, in indicates the input parameter, and out indicates the output parameter,
VARCHAR2 is a parameter type. Pay attention to the if statement and the semicolon.

4. Run F8 until the compilation is successful.

5. Test the stored procedure:

Create a test window and fill in the test code:
Declare
-- Local variables here
V1 varchar2 (20 );
Begin
-- Test statements here
Test_add2 ('hh ', v1 );
Dbms_output.put_line (v1 );

End;

6. Run

In the DBMS Output window, we can see the v1 value of the Output, which is actually the role of dbms_output.

It is useful to add a group. Many enthusiastic netizens thank them.

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.