您的位置:首页 > 其它

Chapter -03 Writing Executable Statements 01

2013-04-18 23:16 316 查看

Objectives

After completing this lesson,you should be able to do the following:

Identify lexical units in a PL/SQL block.

Use build-in SQL functions in PL/SQL

Describe when implict conversions take place and when explict conversion have to be dealt with

Write nested blocks and qualify variables with labels

Write readable code with appropriate indentation

Use sequences in PL/SQL expressions.

Agenda

Writting executable statements in a PL/SQL block

Writting nested blocks

Using operators and developing readable code.

Lexical units in a PL/SQL Block

Lexical units:

Are building blocks of any PL/SQL block.

Are sequences of characters including letters,numerals,tables spaces,returns,and symbols

Can be classified as:

Identifiers:v_fname,c_percent

Delimiters:;,+-

Literals:John,428,True

Comments:--,/**/

PL/SQL Block Syntax and Guidelines

Using Literals

-Character and date literals must be enclosed in single quotation marks.

-Numbers can be simple values or in scientific notaion.

v_name := 'Henderson';


Formatting Code:Statements can span several lines.

View Code

DECLARE
v_outer_variable VARCHAR2(20) := 'GLOBAL VARIABLE';
BEGIN
DECLARE
v_inner_variable VARCHAR2(20) := 'LOCAL VARIABLE';
BEGIN
DBMS_OUTPUT.PUT_LINE(v_inner_variable);
DBMS_OUTPUT.PUT_LINE(v_outer_variable);
END;

DBMS_OUTPUT.PUT_LINE(v_outer_variable);
END;
/
SQL> @nested.sql
LOCAL VARIABLE
GLOBAL VARIABLE
GLOBAL VARIABLE

PL/SQL procedure successfully completed.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: