"Oracle"-Primary PL/SQL

Source: Internet
Author: User

In the recent work to use stored procedures and functions, simply take PL/SQL as a whole to look at. I've seen the basic books and the blog posts in the garden, and I'll summarize what we've learned here.

First, the basic statement

1. Case

2, separators--;

3. Reference string-"'

4, Brackets--()

Ii. Types of data

1. Scalar type

1> numeric Type--number, etc.

2> character Type--CHAR VARCHAR

3> Date Type--date TIMESTAMP INTERVAL

4> Line Identification Type--ROWID Urowid

5> Boolean Type--TURE FALSE NULL

2. Composite type

1> record--similar to C language structure

2> Union Array

3> Nested tables

4> variable length Array

3. Reference type

1> Cursors

2>ref type

4. LOB Type

III. Basic Structure

1. Declaration part--Declare opening

2. Execution part-beginning of begin, end ending

3, exception handling--Exception start

Iv. Constants

Constant name CONSTANT type identifier [not NULL]: = value;

PI CONSTANT Number (9): = 3.1415926;

V. variables

Variable name type identifier [not null]:= value;

%type make a variable get the data type of the field

%rowtype make a variable get the data type of the entire record

Vi. expressions

Numeric expression: +-*/* * (exponentiation)

Character expression: by connector | | Composed of

Relational expressions:< > = = <= >=! = All any between EXISTS in IS-like

Logical expression: not OR and

Seven, operator

Set operator: INTERSECT minus UNION ALL

Row operator: All DISTINCT PRIOR (returns the parent row of the current row when a tree query)

Viii. Conditions of control

1. If condition

If Then END IF;

If Then else END IF;

If Then elsif Then else END IF;

2. Case conditions

Case expression

When value 1 Then

···············;

When value 2 Then

···············;

········

ELSE

···············;

END case;

3. Search-type case conditions

Case

When expression 1 Then

·····················;

When expression 2 Then

····················;

··············

ELSE

·················;

END case;

Nine, Cycle control

1, Loop loop

<<outer>>

Loop Loop loop

······;                ············; ···········;

EXIT;          EXIT when conditional expression; LOOP

END LOOP;                  END LOOP; ············;

EXIT outer when conditional expression; --(two loops are exited)

END LOOP;

END LOOP outer;

2, while LOOP

While-expression loop

············;

END LOOP;

3, for LOOP

For I in 1..5 LOOP

············;

END LOOP;

Ten, other functional characteristics

1. Cursors

2. Process

3. Functions

4. Package

5. Collection

6. Error handling

  

"Oracle"-Primary PL/SQL

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.