Oracle pl/SQL programming Basics

Source: Internet
Author: User

What pl/SQL must understand:
1. process, function, trigger is pl/SQL programming
2. process, function, and trigger are in Oracle
3. pl/SQL is a very powerful database process Language
4. process. functions can be called in java programs.

----------------------------------------------------------
I will not talk about the advantages of pl/SQL.
Disadvantages:
Poor portability
----------------------------------------------------------
1. Write a stored procedure that can add records to a table
Created procedure process name is
Begin
Insert into table name values (Field 1, Field 2)
End;

Created or replace procedure process name is
Begin
Insert into table name values (Field 1, Field 2)
End
Replace indicates that if this exists, replace it.
View error information
Show error;

----------------------------------------------------------
Block Structure
A pl/SQL block consists of three parts: definition, execution, and exception,
As follows:
Declear
/* Definition section ------- define constants, variables, cursors, exceptions, and complex data types */
Begin
/* Execution part --- the pl/SQL statements to be executed and SQL statements */
Exception
/* Exception Handling Section ----- handle various running errors */
End;

Note:
The definition starts with declare,
This part is optional
The execution part starts from begin.
This part is required
The exception starts with exception.
This part is optional
---------------------------------------------------------

 

 

How to call this process
1. exec process name (parameter 1, parameter 2 ...);
2. call process name (parameter 1, parameter 2 ...);

 

----------------------------------------------------------
Oracle coding specifications
1. Notes:
Single line comment --
Multi-line comment /*.....*/

2. Identity symbol naming rules
1) when defining a variable, we recommend that you use v _ as the prefix v_sal.
2) when defining a constant, we recommend that you use c _ as the prefix c_rate.
3) when defining a cursor, we recommend using _ cursor as the suffix emp_cursor;
4) when defining an exception, we recommend that you use e _ as the prefix e_error;

----------------------------------------------------------

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.