易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle Procedure 数组参数的应用

因工作需要,数据库由PostgreSQL 转为Oracle 10g。由于之前的逻辑几乎都分布于存储过程,所以多代码的修改相对来说较小。
因对Oracle 数组参数的转换花了些时间,所以记录下来,分享一下。言归正传:
如果入参为字符串数组、整形数组或者GUID数组等等,并且把它作为一个查询条件,有两种方法可以做到。我采用了package,后面将介绍原因。
方法一:
在存储过程中使用for,相信大家对此应该不陌生。上例子:
create or replace package sbp_disablesyncpreset
as
type string_array is table of raw(16) index by binary_integer;
procedure disablesyncpreset(sync_computers in string_array, active_presets in string_array);
end sbp_disablesyncpreset;
Commit;
create or replace package body sbp_disablesyncpreset
as
procedure disablesyncpreset(sync_computers in string_array, active_presets in string_array)
as
begin
FOR i IN sync_computers.FIRST .. sync_computers.LAST
LOOP
UPDATE sparesync_last_sync SET preset_active='0'
WHERE
((destination_guid=sync_computers(i)) OR (src_guid=sync_computers(i))) AND (NOT preset_id=active_presets(i));
END LOOP;
end disablesyncpreset;
end sbp_disablesyncpreset;
Commit;
 
方法二:使用自己定义的全局数组类型,上例子:
create or replace package sbp_disablesyncpreset
as
type string_array is table of raw(16) index by binary_integer; //定义数组类型,与入参一致
procedure disablesyncpreset(sync_computers in string_array);//存贮过程名称
end sbp_disablesyncpreset;
Commit;
//主体部分
create or replace package body sbp_disablesyncpreset
as
procedure disablesyncpreset(sync_computers in string_array)
as
computerguids spu_nested_type20 := spu_nested_type20(); //自己定义的全局数组类型
begin
FOR i IN computerid.first..computerid.last loop
computerguids.extend;
computerguids(i) := computerid(i);
end loop;

UPDATE sparesync_last_sync SET preset_active='0'
WHERE
destination_guid in (select column_value from table(Cast(computerguids as spu_nested_type20)))
OR src_gui


相关文档:

ORACLE的几种启动方式


[精华] ORACLE的几种启动方式
http://www.chinaunix.net 作者:wuwenlong  发表于:2003-07-27 16:58:57
【发表评论】 【查看原文】 【Oracle讨论区】【关闭】
1、startup nomount 
   非安装启动,这种方式启动下可执行:重建控制文件、重建数据库 
   读取 ......

Oracle Database Tuning ADDM

ADDM (Automatic Database Diagnostic Monitor) implements the Oracle performance method and analyzes statistics to provide automatic diagnosis of major performance problems. Because ADDM can significantly shorten the time required to improve the performance of a system, it is one of the most used perf ......

使用Oracle Text进行全文检索

由于系统中数据不断增多,使得原用的like语法来进行查询法律全文变得十分缓慢,因此在原有系统中增加了全文检索的功能。
  全文检索功能依赖于Oracle Text。首先保证Oracle Text组件在数据库中已安装。然后建立索引
  Sql代码
  --法律全文内容字段增加索引
  create index idx_flqw_nr on flqw(nr) indextype ......

oracle行列转换

/* 
在实际使用sql工作中总会碰到将某一列的值放到标题中显示.就是总说的行列转换或者互换. 
比如有如下数据: 
ID NAME       KECHENG              CHENGJI 
-- ---------- --------------- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号