Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PL/SQL structure

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Unnamed blocks: unnamed block

Named blocks: procedures, functions, packages, and triggers

Definition section: used to define variables, constants, cursors, triggers, compound data types

Executive part: used to implement the function of the application module, including PL/SQL statements and SQL statements to be executed

Exception handling part: used to handle possible running errors in the execution part

[DECLARE

...-definition section]

BEGIN

..-- the executive part

[EXCEPTION

.-- exception handling part]

END

-

DECLARE

A NUMBER

BEGIN

ARV 1: 2

DBMS_OUTPUT.PUT_LINE ('1 / 2 / 1 / 2 / 2) | | a)

EXCEPTION

WHEN OTHERS THEN

DBMS_OUTPUT.PUT_LINE ('exception')

END

/

Conditional branching statement:

DECLARE

A1 number: = 100

A2 number: = 200

BEGIN

IF A1 > a2 THEN

DBMS_OUTPUT.PUT_LINE ('A1 is larger than a2')

ELSIF a1=a2 THEN

DBMS_OUTPUT.PUT_LINE ('A1 is equal to a2')

ELSE

DBMS_OUTPUT.PUT_LINE ('A1 is smaller than a2')

ENDIF

END

/

DECLARE

Grade CHAR (1): ='B'

Appraisal VARCHAR2 (20)

BEGIN

Appraisal: =

CASE grade

WHEN'A 'THEN' excellent'

WHEN'B' THEN 'good'

WHEN'C 'THEN'

WHEN'D' THEN 'pass'

WHEN'F'THEN 'failed'

ELSE 'does not have such a rating'

DBMS_OUTPUT.PUT_LINE ('Grade' | | grade | |' is' | | appraisal)

END

/

Loop statement:

DECLARE

Total number: = 0

Salary number: = 1800

BEGIN

LOOP

Total: = total + salary

EXIT WHEN total > 2500

END LOOP

DBMS_OUTPUT.PUT_LINE ('total salary is' | | total)

END

/

DECLARE

Total number: = 0

Salary number: = 1800

BEGIN

WHILE total

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report