- 浏览: 909758 次
- 性别:
- 来自: 黑龙江
文章分类
- 全部博客 (209)
- struts1 (3)
- hibernate3 (19)
- java (13)
- spring2 (5)
- netBeans (1)
- eclipse (1)
- JSF (1)
- DIV+CSS篇章 (1)
- jFreeChart+Oracle之曲线,柱状及饼状图的实现 (1)
- JSF知识与技巧 (3)
- Oracle数据类型的介绍与比较 (2)
- J2EE (2)
- Ajax技术 (4)
- javaScript技术 (25)
- struts2 (16)
- C/C++程序设计 (1)
- oracle系统学习 (29)
- 算法分析 (0)
- Linux实践 (7)
- extjs开发经验 (13)
- flex开发总结 (1)
- FusionCharts总结 (0)
- 高级数据库总结 (0)
- SVG拓扑图开发总结 (0)
- CSS (1)
- CSS使用简介 (1)
- SVG (0)
- DOJO (0)
- Junit测试 (0)
- lucene (24)
- solr (6)
- tokyo tyrant 技术 (7)
- Html5 (1)
- 算法与数据结构 (0)
- 物联网相关技术学习 (0)
- UI设计 (1)
- webservice (0)
- Android (5)
- hibernate4 (3)
- solrcloud (0)
- dorado5 (0)
- dorado7 (0)
- elasticsearch (0)
- GWT (0)
- node.js (0)
- 并发编程 (1)
- 大数据 (1)
- 项目经验 (5)
最新评论
-
cs261244787:
楼主好人! 平安
struts2,hibernate4,spring3配置时问题汇总及解决办法 -
wxluck666:
我也赞一个 很有用
struts2,hibernate4,spring3配置时问题汇总及解决办法 -
wxluck666:
我也赞一个 很有用
struts2,hibernate4,spring3配置时问题汇总及解决办法 -
xinsiyou:
牛逼,就是样式被搞没了
JS实现选项右移,左移,向上,向下调整顺序 -
unnamed__:
这代码风格就像一坨翔
java获取数据库的列名,类型等信息
PL/SQL编程(高级特性)2009年04月09日 星期四 11:20--set serveroutput On--打开显示模式
declare
type cust_record_type is record(--定义记录类型
customer_name customer.customer_name%type,--声明标量变量
customer_status customer.customer_status%type--声明记录变量
);
cust_record cust_record_type;
begin
select a.customer_name ,a.customer_status into cust_record from customer a Where Rownum=1 ;
--where a.customer_id=b.customer_id and b.ord_id=&id;
dbms_output.put_line('客户名:'||cust_record.customer_name);
dbms_output.put_line('状态:'||cust_record.customer_status);
end;
/*********************************************************
Author:qinyangzhao
describe:%rowtype属性(rowtype)
*********************************************************/
declare
product_record product%rowtype;
begin
product_record.product_id:=&id;
product_record.description:='&description';
insert into product values product_record;
end;
/*********************************************************
Author:qinyangzhao
describe:索引表(table)
*********************************************************/
declare
type item_table_type is table of item.ename%type
index by pls_integer;
item_table item_table_type;
begin
select * bulk collect into item_table(-1)
from item where ord_id=&id;
dbms_output.put_line('条款编号:'||item_table(-1));
end;
/*********************************************************
Author:qinyangzhao
describe:嵌套表(table)
*********************************************************/
declare
type item_table_type is table of item.ename%type;
item_table item_table_type;
begin
item_table:=item_table_type('mary','mary','mary');
select ename into item_table(2) from item
where empno=&no;
dbms_output.put_line('雇员名:'||item_table(2));
end;
/*********************************************************
Author:qinyangzhao
describe:变长数组(array)
*********************************************************/
declare
type name_array_type is varray(20) of varchar2(30);
type city_array_type is varray(20) of varchar2(30);
name_array name_array_type;
city_array city_array_type;
begin
select name ,city bulk collect
into name_array,city_array from customer;
for i in 1..name_array.count loop
dbms_output.put_line('客户名:'||name_array(i)||',所在城市:'||city_array(i));
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:记录表(table)
*********************************************************/
declare
type item_table_type is table of item%rowtype
index by pls_integer;
item_table item_table_type;
begin
select * bulk collect into item_table
from item where ord_id=&id;
for i in 1..item_table.count loop
dbms_output.put_line('条款编号:'||item_table(i).item_id||',总价:'||
item_table(i).total);
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:多级(varray)
*********************************************************/
declare
type al_varray_type is varray(10) of int;--定义一维varray
type nal_varray_type is varray(10) of al_varray_type;--定义二维varrary集合
--初始化二维集合变量
nvl nal_varrary_type:=nal_varrary_type(
al_varray_type(58,100,102),
al_varray_type(55,6,73),
al_arrary_type(2,4));
begin
dbms_output.put_line('显示二维数组所有元素');
for i in 1..nvl.count loop
for j in 1..nvl(i).count loop
dbms_output.put_line('nvl('||i||','||j||')='||nvl(i,j));
end loop;
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:多级(嵌套)
*********************************************************/
declare
type al_table_type is table of int;--定义一维嵌套表
type nal_table_type is table of al_table_type;--定义二维嵌套表集合
--初始化二维集合变量
nvl nal_varrary_type:=nal_varrary_type(
al_varray_type(58,100,102),
al_varray_type(55,6,73),
al_arrary_type(2,4));
begin
dbms_output.put_line('显示二维数组所有元素');
for i in 1..nvl.count loop
for j in 1..nvl(i).count loop
dbms_output.put_line('nvl('||i||','||j||')='||nvl(i,j));
end loop;
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:多级(索引表)
*********************************************************/
declare
type al_table_type is table of int
index by binary_integer;--定义一维table
type nal_table_type is table of al_table_type
index by binary_integer;--定义二维table集合
nvl nal_varrary_type;
begin
--初始化二维集合变量
nvl(1)(1):=10;
nvl(1)(2):=5;
nvl(2)(1):=32;
nvl(2)(2):=88;
dbms_output.put_line('显示二维数组所有元素');
for i in 1..nvl.count loop
for j in 1..nvl(i).count loop
dbms_output.put_line('nvl('||i||','||j||')='||nvl(i,j));
end loop;
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:处理多行查询语句
*********************************************************/
declare
type empcurtyp is ref cursor;
emp_cv empcurtyp;
emp_record emp%rowtype;
sql_stat varchar2(100);
begin
sql_stat:='select * from emp where deptno:=dno';
open emp_cv for sql_stat using &dno;
loop
fetch emp_cv into emp_record;
exit when emp_cv%notfound ;
dbms_output.put_line('雇员名:'||emp_record.ename||',工资:'||emp_record.sal);
end loop;
close emp_cv;
end;
/*********************************************************
Author:qinyangzhao
describe:使用bulk子句处理dml语句返回子句
*********************************************************/
declare
type ename_table_type is table of emp.ename%type
index by binary_integer;
type sal_table_type is table of emp.sal%type
index by binary_integer;
ename_table ename_table_type;
sal_table sal_table_type;
sql_stat varchar2(100);
begin
sql_stat:='update emp set sal=sal*(1+:percent/100)'
||'where deptno=:dno'
||'returning ename,sal into :name,:salary';
execute immediate sql_stat using &percen ,&dno returning bulk collect into ename_table,sal_table;
for i in 1..ename_table.count loop
dbms_output.put_line('雇员:'||ename_table(i)
||',的新工资为'|| sal_table(i));
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:使用bulk子句处理多行查询
*********************************************************/
declare
type ename_table_type is table of emp.ename%type
index by binary_integer;
ename_table ename_table_type;
sql_stat varchar2(100);
begin
sql_stat:='select ename from emp where deptno+:dno';
execute immediate sql_stat bulk collect into ename_table using &dno;
for i in 1..ename_table.count loop
dbms_output.put_line(ename_table(i));
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:在fetch语句中使用bulk子句
*********************************************************/
declare
type empcurtyp is ref cursor;
emp_cv empcurtyp ;
type ename_table_type is table of emp.ename%type
index by binary_integer;
ename_table ename_table_type;
sql_stat varchar2(100);
begin
sql_stat:='select ename from emp where job:title';
open emp_cv for sql_stat using '&job';
fetch emp_cv bulk collect into ename_table;
for i in 1..ename_table.count loop
dbms_output.put_line(ename_table(i));
end loop;
close emp_cv;
end;
/*********************************************************
Author:qinyangzhao
describe:在forall语句中使用bulk子句
*********************************************************/
declare
type ename_table_type is table of emp.ename%type;
type sal_table_type is table of emp.sal%type;
ename_table ename_table_type;
sal_table sal_table_type;
sql_stat varchar2(100);
begin
ename_table:=name_table_type('scott','smith','clark');
sql_stat:='update emp set sal=sal*1.1 where ename=:1'
||'returning sal into :2';
forall i in 1..ename_talbe.count
execute immediate sql_stat using ename_table(i)
returing bulk collect into sal_table ;
for j in 1..ename_table.count loop
dbms_output.put_line('雇员'||ename_table(j)
||'的新工资为'||sal_table(j));
end loop;
end;
declare
type cust_record_type is record(--定义记录类型
customer_name customer.customer_name%type,--声明标量变量
customer_status customer.customer_status%type--声明记录变量
);
cust_record cust_record_type;
begin
select a.customer_name ,a.customer_status into cust_record from customer a Where Rownum=1 ;
--where a.customer_id=b.customer_id and b.ord_id=&id;
dbms_output.put_line('客户名:'||cust_record.customer_name);
dbms_output.put_line('状态:'||cust_record.customer_status);
end;
/*********************************************************
Author:qinyangzhao
describe:%rowtype属性(rowtype)
*********************************************************/
declare
product_record product%rowtype;
begin
product_record.product_id:=&id;
product_record.description:='&description';
insert into product values product_record;
end;
/*********************************************************
Author:qinyangzhao
describe:索引表(table)
*********************************************************/
declare
type item_table_type is table of item.ename%type
index by pls_integer;
item_table item_table_type;
begin
select * bulk collect into item_table(-1)
from item where ord_id=&id;
dbms_output.put_line('条款编号:'||item_table(-1));
end;
/*********************************************************
Author:qinyangzhao
describe:嵌套表(table)
*********************************************************/
declare
type item_table_type is table of item.ename%type;
item_table item_table_type;
begin
item_table:=item_table_type('mary','mary','mary');
select ename into item_table(2) from item
where empno=&no;
dbms_output.put_line('雇员名:'||item_table(2));
end;
/*********************************************************
Author:qinyangzhao
describe:变长数组(array)
*********************************************************/
declare
type name_array_type is varray(20) of varchar2(30);
type city_array_type is varray(20) of varchar2(30);
name_array name_array_type;
city_array city_array_type;
begin
select name ,city bulk collect
into name_array,city_array from customer;
for i in 1..name_array.count loop
dbms_output.put_line('客户名:'||name_array(i)||',所在城市:'||city_array(i));
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:记录表(table)
*********************************************************/
declare
type item_table_type is table of item%rowtype
index by pls_integer;
item_table item_table_type;
begin
select * bulk collect into item_table
from item where ord_id=&id;
for i in 1..item_table.count loop
dbms_output.put_line('条款编号:'||item_table(i).item_id||',总价:'||
item_table(i).total);
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:多级(varray)
*********************************************************/
declare
type al_varray_type is varray(10) of int;--定义一维varray
type nal_varray_type is varray(10) of al_varray_type;--定义二维varrary集合
--初始化二维集合变量
nvl nal_varrary_type:=nal_varrary_type(
al_varray_type(58,100,102),
al_varray_type(55,6,73),
al_arrary_type(2,4));
begin
dbms_output.put_line('显示二维数组所有元素');
for i in 1..nvl.count loop
for j in 1..nvl(i).count loop
dbms_output.put_line('nvl('||i||','||j||')='||nvl(i,j));
end loop;
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:多级(嵌套)
*********************************************************/
declare
type al_table_type is table of int;--定义一维嵌套表
type nal_table_type is table of al_table_type;--定义二维嵌套表集合
--初始化二维集合变量
nvl nal_varrary_type:=nal_varrary_type(
al_varray_type(58,100,102),
al_varray_type(55,6,73),
al_arrary_type(2,4));
begin
dbms_output.put_line('显示二维数组所有元素');
for i in 1..nvl.count loop
for j in 1..nvl(i).count loop
dbms_output.put_line('nvl('||i||','||j||')='||nvl(i,j));
end loop;
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:多级(索引表)
*********************************************************/
declare
type al_table_type is table of int
index by binary_integer;--定义一维table
type nal_table_type is table of al_table_type
index by binary_integer;--定义二维table集合
nvl nal_varrary_type;
begin
--初始化二维集合变量
nvl(1)(1):=10;
nvl(1)(2):=5;
nvl(2)(1):=32;
nvl(2)(2):=88;
dbms_output.put_line('显示二维数组所有元素');
for i in 1..nvl.count loop
for j in 1..nvl(i).count loop
dbms_output.put_line('nvl('||i||','||j||')='||nvl(i,j));
end loop;
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:处理多行查询语句
*********************************************************/
declare
type empcurtyp is ref cursor;
emp_cv empcurtyp;
emp_record emp%rowtype;
sql_stat varchar2(100);
begin
sql_stat:='select * from emp where deptno:=dno';
open emp_cv for sql_stat using &dno;
loop
fetch emp_cv into emp_record;
exit when emp_cv%notfound ;
dbms_output.put_line('雇员名:'||emp_record.ename||',工资:'||emp_record.sal);
end loop;
close emp_cv;
end;
/*********************************************************
Author:qinyangzhao
describe:使用bulk子句处理dml语句返回子句
*********************************************************/
declare
type ename_table_type is table of emp.ename%type
index by binary_integer;
type sal_table_type is table of emp.sal%type
index by binary_integer;
ename_table ename_table_type;
sal_table sal_table_type;
sql_stat varchar2(100);
begin
sql_stat:='update emp set sal=sal*(1+:percent/100)'
||'where deptno=:dno'
||'returning ename,sal into :name,:salary';
execute immediate sql_stat using &percen ,&dno returning bulk collect into ename_table,sal_table;
for i in 1..ename_table.count loop
dbms_output.put_line('雇员:'||ename_table(i)
||',的新工资为'|| sal_table(i));
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:使用bulk子句处理多行查询
*********************************************************/
declare
type ename_table_type is table of emp.ename%type
index by binary_integer;
ename_table ename_table_type;
sql_stat varchar2(100);
begin
sql_stat:='select ename from emp where deptno+:dno';
execute immediate sql_stat bulk collect into ename_table using &dno;
for i in 1..ename_table.count loop
dbms_output.put_line(ename_table(i));
end loop;
end;
/*********************************************************
Author:qinyangzhao
describe:在fetch语句中使用bulk子句
*********************************************************/
declare
type empcurtyp is ref cursor;
emp_cv empcurtyp ;
type ename_table_type is table of emp.ename%type
index by binary_integer;
ename_table ename_table_type;
sql_stat varchar2(100);
begin
sql_stat:='select ename from emp where job:title';
open emp_cv for sql_stat using '&job';
fetch emp_cv bulk collect into ename_table;
for i in 1..ename_table.count loop
dbms_output.put_line(ename_table(i));
end loop;
close emp_cv;
end;
/*********************************************************
Author:qinyangzhao
describe:在forall语句中使用bulk子句
*********************************************************/
declare
type ename_table_type is table of emp.ename%type;
type sal_table_type is table of emp.sal%type;
ename_table ename_table_type;
sal_table sal_table_type;
sql_stat varchar2(100);
begin
ename_table:=name_table_type('scott','smith','clark');
sql_stat:='update emp set sal=sal*1.1 where ename=:1'
||'returning sal into :2';
forall i in 1..ename_talbe.count
execute immediate sql_stat using ename_table(i)
returing bulk collect into sal_table ;
for j in 1..ename_table.count loop
dbms_output.put_line('雇员'||ename_table(j)
||'的新工资为'||sal_table(j));
end loop;
end;
发表评论
-
数据表更名语句
2010-04-21 11:08 1196当前数据表名为A,想要更名为B的语句如下: alter tab ... -
ORA-01078 & LRM-00109错误解决方法
2010-03-23 16:40 5447一同事今天刚装完oracle10g后,通过startup命令启 ... -
在线修改redo.log文件的大小
2009-09-02 17:24 59221.查看当前日志组成员: SQL> select mem ... -
怎么确保最终用户在数据库中只有一个会话
2009-08-11 18:47 1480sqlplus / as sysdba create user ... -
测试版-逻辑switchover
2009-07-16 12:41 12121.检查primary数据库是否配置了standby redo ... -
测试版-逻辑standby创建
2009-07-16 12:37 22581、创建物理standby 详见《测试版-物理standb ... -
测试版-物理switchover
2009-07-16 12:35 1058注意:standby数据库应该是alter database ... -
测试版-物理standby创建
2009-07-15 17:37 12521.编辑/etc/hosts文件 # vi /etc/ho ... -
dataguard日志传输方式简介
2009-06-26 12:44 52521、两种日志传输方式 Arch:传统的日志传送方式。现在只 ... -
物理standby的failover
2009-06-26 12:40 1195========================物理stand ... -
物理standby的Switchover
2009-06-26 12:39 1234=======================物理st ... -
dataguard保护模式介绍
2009-06-26 12:38 32861、三种保护模式 1).最大性能(maximize per ... -
查看pga和sga值
2009-05-27 01:07 2489--显示正在使用的参数和文本参数值 1)select * fr ... -
设置sga和pga的值
2009-05-27 01:05 2496--设置sga的值 1)alter system set sg ... -
表的创建时间和表的大小空间
2009-05-27 01:04 1323--查看表的创建时间 select created,last_ ... -
设置parallel_automatic_tuning参数之后的错误的解决方法
2009-05-27 01:02 1724--设置并行度 1)alter system set para ... -
HA、RAC、Datagurad的区别
2009-05-10 20:20 2444标题为:HA、RAC、Datagurad的区别 一.HA简介 ... -
通过shell脚本后台创建表空间
2009-05-10 20:16 20601.用oracle用户登陆并创建shell文件: $ vi / ... -
occi库文件替换
2009-05-10 20:08 20611.从官方下载occi_gcc343_x86_64_10203 ... -
oracle10g查看表空间信息
2009-05-10 20:06 2963SELECT UPPER(F.TABLESPACE_NAME) ...
相关推荐
《Oracle PL/SQL程序设计(第5版)》基于Oracle数据库11g,从PL/SQL编程、PL/SQL程序结构、PL/SQL程序数据、PL/SQL中的SQL、PL/SQL应用构建、高级PL/SQL主题这6个方面详细系统地讨论了PL/SQL以及如何有效地使用它。...
PL/SQL本身涉及的知识点浩瀚、庞杂...当然,最为重要的还是内容本身,本书首先对PL/SQL的理论基础进行了全面的介绍,其次详细讲解PL/SQL开发的所有功能模块、方法和技巧,最后对它的各种高级特性也进行了深入探讨。
《Oracle PL/SQL程序设计(第5版)》基于Oracle数据库11g,从PL/SQL编程、PL/SQL程序结构、PL/SQL程序数据、PL/SQL中的SQL、PL/SQL应用构建、高级PL/SQL主题这6个方面详细系统地讨论了PL/SQL以及如何有效地使用它。...
对于PL/SQL开发人员,可能已经非常熟悉PL/SQL的基本开发方法,但可能对PL/SQL高级内容(集合类型,对象类型,LOB对象处理)和oracle9i/oracle10g的PL/SQL新特性知之较少,本书对于这些高级知识和新特性有非常详尽的介绍....
ORACLE数据库除了提供SQL和PL/SQL来访问数据库外,还提供了一个第三代程序设计语言的接口,用户可以通过C、COBOL、FORTRAN等第三代语言来编程访问数据库。OCI就是为了实现高级语言访问数据库而提供的接口。OCI允许...
5.2 基本PL/SQL编程结构 5.3 定义PL/SQL数据类型 5.3.1 有效字符集 5.3.2 算术操作符 5.3.3 varchar2类型 5.3.4 数字类型 5.3.5 日期类型 5.3.6 布尔类型 5.4 在SQL*Plus中编写PL/SQL程序, 5.4.1 PL/SQL程序中...
该资料是《Oracle SQL高级编程》的源代码 对应的书籍资料见: Oracle SQL高级编程(资深Oracle专家力作,OakTable团队推荐) 基本信息 原书名: Pro Oracle SQL 原出版社: Apress 作者: (美)Karen Morton Kerry ...
本书内容包括Oracle数据库的基本概念;Oracle数据库结构和实用程序;...高级SQL特性;用interMedia、基于C的外部过程、Java存储过程和对象关系特性实现Oracle数据库功能的扩展;Oracle数据库安全管理的实现方式等。
5.2 基本PL/SQL编程结构 123 5.3 定义PL/SQL数据类型 124 5.3.1 有效字符集 124 5.3.2 算术操作符 125 5.3.3 varchar 2类型 126 5.3.4 数字类型 127 5.3.5 日期类型 127 5.3.6 布尔类型 128 5.4 在SQL*Plus...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...
此外还有大量案例:Where In List问题解析,数据库设计和大数据量处理、数据审核、号段选取应用、分析SQL执行计划的关注点、Oracle开发误区探索、提升PL/SQL开发性能漫谈、管道函数的学习与实战应用、巧用锁特性避免...