oracle程序开发基础一
2006-06-22 11:54
369 查看
基础
什么是PL/SQL?
PL/SQL的英文全称是(Procedural Language Structured Query Language),是过程语言结构化查询语言,是直接驻留在数据库
中的编程环境。
下面是PL/SQL编程中应注意的方面:
1、变量附值是使用":="符号。
通用格式: variable_name variable_type :=value;
例如: i number :=0;
常用的数据类型:varchar2,number,date,boolean.
2、控制结构
if逻辑结构
一、
if 条件 then
语句;
end if;
例如:
if l_date>'12-APR-03' then
语句;
end if
注意:与很多其他编程语言不同,if后面不直接加括号
但是可以这样用:
if not(l_date<='12-APR-03') then
语句;
end if
与上面语句等效
二、
if 条件 then
语句;
else
语句;
end if;
三、
if 条件 then
语句;
elsif 条件 then
语句;
end if;
循环结构
一、
while循环
while 条件 loop
语句;
end loop;
二、
for循环(非常特殊)
for l_counter in 1..5 --循环5次,变量l_counter的值从1一直递增到5.(在in 后面加 reverse,可以递减计数)
loop
语句;
end loop;
一个例子:
使用serveroutput和dbms_output函数
首先把输出工具打开:set serveroutput on size 100000
在sql下输入如下:
SQL> declare
2 l number;
3 begin
4 for l in reverse 1..5
5 loop
6 dbms_output.put_line(l);
7 end loop;
8 end;
/
就可以看到运行结果了
什么是PL/SQL?
PL/SQL的英文全称是(Procedural Language Structured Query Language),是过程语言结构化查询语言,是直接驻留在数据库
中的编程环境。
下面是PL/SQL编程中应注意的方面:
1、变量附值是使用":="符号。
通用格式: variable_name variable_type :=value;
例如: i number :=0;
常用的数据类型:varchar2,number,date,boolean.
2、控制结构
if逻辑结构
一、
if 条件 then
语句;
end if;
例如:
if l_date>'12-APR-03' then
语句;
end if
注意:与很多其他编程语言不同,if后面不直接加括号
但是可以这样用:
if not(l_date<='12-APR-03') then
语句;
end if
与上面语句等效
二、
if 条件 then
语句;
else
语句;
end if;
三、
if 条件 then
语句;
elsif 条件 then
语句;
end if;
循环结构
一、
while循环
while 条件 loop
语句;
end loop;
二、
for循环(非常特殊)
for l_counter in 1..5 --循环5次,变量l_counter的值从1一直递增到5.(在in 后面加 reverse,可以递减计数)
loop
语句;
end loop;
一个例子:
使用serveroutput和dbms_output函数
首先把输出工具打开:set serveroutput on size 100000
在sql下输入如下:
SQL> declare
2 l number;
3 begin
4 for l in reverse 1..5
5 loop
6 dbms_output.put_line(l);
7 end loop;
8 end;
/
就可以看到运行结果了
相关文章推荐
- oracle程序开发基础二
- Linux及Arm-Linux程序开发笔记(零基础入门篇)
- 小飞鱼网络平台课程 OA开发程序基础课 2月15日 第一课 HTML基础课件及作业
- Oracle PL/SQL开发基础(第二弹:使用数据字典视图查看表约束)
- 程序开发基础学习一(uml设计)
- 微信小程序开发系列——4.小程序视图页面基础知识
- Oracle PL/SQL开发基础(第二十九弹:异常处理简介)
- 编写跨平台Java程序注意事项-Java基础-Java-编程开发
- 如何使用Java编写多线程程序-Java基础-Java-编程开发
- 程序开发基础学习四(boost::signal2 函数学习)
- 程序人生:Java三个月—OOP的乐趣-Java基础-Java-编程开发
- 基于Oracle的高性能动态SQL程序开发
- Oracle PL/SQL开发基础(第三十四弹:RAISE_APPLICATION_ERROR)
- 微信小程序开发&电影小程序——基础目录、欢迎页面的创建。
- 微信小程序开发(基础)
- 计算机系统基础笔记:程序的开发和执行及其支撑环境
- 游戏程序开发基础(客户端篇)之一
- Oracle PL/SQL开发基础(第十七弹:集合类型)
- [原]java专业程序代写(qq:928900200),学习笔记之基础入门<Oracle_基础>(三十三)
- J2ME程序开发全方位基础讲解汇总