[PL/SQL]10g PL/SQL学习笔记(一)

PL/SQL block structure

Declare(可选)

Begin

Executable(必须)

sqlpl/sql

Exception(可选,嵌在executable部分)

end;

block types

1. Anonymous

2. procedure

3. fuction(必须返回值)

isql*plus中输出

Set serveroutput on

Delimiters in String Literals

event VARCHAR2(15):='Father''s day';

You can specify any character that is not present in the string as delimiter. The slide shows how to use the q' notation to specify the delimiter. The examples use ‘!’ and ‘[‘ as delimiters. Consider the following example:

event := q'!Father's day!';

PL/SQL variables type

Scalar

Composite

Reference

Large object (LOB)

%TYPE Attribute

用于声明一个变量,它的类型与某一列或某一个变量类型相同。列中的not null属性并不被继承。

emp_lname employees.last_name%TYPE;

balance NUMBER(7,2);

min_balance balance%TYPE := 1000;

Bind Variables

VARIABLE return_code NUMBER

Substitution Variables

PL/SQL执行之前值就代入,所以无法在循环中使用。

Using DEFINE for a User Variable

可以使用DEFINE定义一个用户变量,只能是char类型

DEFINE lname= Urman

SELECT first_name INTO fname FROM employees

WHERE last_name='&lname';

Lexical Units in a PL/SQL Block

Identifiers

Delimiters

Literals

Comments

Commenting Code

单行:--

多行:/* … */

Variable Scope and Visibility

一个变量只在声明的块中可见(包括nested block

对于同名变量,首先搜索当前块,未找到再去找outer block

Programming Guidelines

Documenting code with comments

Developing a case convention for the code

Developing naming conventions for identifiers and other objects

Enhancing readability by indenting

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8558093/viewspace-1014187/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8558093/viewspace-1014187/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值