使用集合变量作为输入参数CREATETYPEdeptno_table_typeISTABLEOFNUMBER(2);/CREATETYPEdname_table_typeISTABLEOFVARCHAR2(10);/CREATETYPEloc_table_typeISTABLEOFVARCHAR2(20);/CREATEORREPLACEPROCEDUREadd_department(deptno_tabledeptno_table_type,dname_tabledname_table_type,loc_tableloc_table_type)ISBEGINFORALLiIN1..deptno_table.COUNTINSERTINTOdeptVALUES(deptno_table(i),dname_table(i),loc_table(i));EXCEPTIONWHENDUP_VAL_ON_INDEXTHENRAISE_APPLICATION_ERROR(-20012,'部门号不能重复');END;/DECLAREdeptno_tabledeptno_table_type:=deptno_table_type(60,70,80);dname_tabledname_table_type:=dname_table_type('计划处','质量处','技术处');loc_tableloc_table_type:=loc_table_type('呼和浩特','包头','乌海');BEGINadd_department(deptno_table,dname_table,loc_table);END;/18-18:使用集合变量作为输出参数CREATETYPEename_table_typeISTABLEOFVARCHAR2(10);/CREATETYPEjob_table_typeISTABLEOFVARCHAR2(10);/CREATEORREPLACEPROCEDUREget_emp(dnoNUMBER,ename_tableOUTename_table_type,job_tableOUTjob_table_type)ISBEGINSELECTename,jobBULKCOLLECTINTOename_table,job_tableFROMempWHEREdeptno=dno;EXCEPTIONWHENNO_DATA_FOUNDTHENRAISE_APPLICATION_ERROR(-20010,'该部门不存在');END;/DECLAREename_tableename_table_type;job_tablejob_table_type;BEGINget_emp(&dno,ename_table,job_table);FORiIN1..ename_table.COUNTLOOPdbms_output.put_line('姓名:'||ename_table(i)||',岗位:'||job_table(i));ENDLOOP;END;/
下面是存储过程代码:
declare
except_arrayarray_num:=array_num(90818041);
from_catalogidnumber:=90818040;
to_catalogidnumber:=91469311;
begin
directory_path_change(from_catalogid,to_catalogid,except_array);
end
;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
create or replace procedure directory_path_change(from_catalogId integer ,to_catalogId integer ,except_arrayarray_num) is
tmp_IDNUMBER(19);
catalog_treepathVARCHAR2(768 CHAR );
inumber(10);
isUpdatenumber(1);
cursor directory_cursor is
select id from corp_directorysd where d.catalog_id=from_catalogId;
begin
select treepath into catalog_treepath from corp_catalogs where id=to_catalogId;
savepointp1;
open directory_cursor;
loop
fetch directory_cursor into
tmp_ID;
exit when directory_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( '=============ID:' );
DBMS_OUTPUT.PUT_LINE(tmp_ID);
i:=1;
isUpdate:=0;
for i in 1..except_array. count Loop
ifexcept_array(i)=tmp_ID then
isUpdate:=1;
end if;
end loop;
ifisUpdate=1 then
update corp_directorysd set d.catalog_id=to_catalogId,d.treepath=(catalog_treepath||d.id|| '#' ) where d.id=tmp_ID;
end if;
commit ;
end loop;
close directory_cursor;
exception
when others then
dbms_output.put_line(sqlerrm);
rollback to savepointp1;
end directory_path_change;
|
分享到:
相关推荐
就测试过程本身而言,应该包含以s下几个阶段。 -测试需求的分析和确定。 -测试计划。 -测试设计。 -测试执行。 -测试记录和缺陷跟踪。 -回归测试。 -测试总结和报告。 一个好的测试管理工具...
一、填空 1.在多进程Oracle实例系统中,进程分为用户进程、后台进程和服务进程。 2.标准的SQL语言语句类型可以分为:数据定义语句(DDL)、数据操纵语句(DML)... Oracle数据库中角色分为系统预定义的角色和用户自定义的...
过程:Create or replace procedure procname(参数列表) as PL/SQL语句块 函数:Create or replace function funcname(参数列表) return 返回值 as PL/SQL语句块 为便于理解,举例如下: 问题:假设有一张表t1,有f1...
PL/SQL Developer是一个集成开发环境,专门面向Oracle数据库存储程序单元的开发。如今,有越来越多的商业逻辑和应用逻辑转向了Oracle Server,因此,PL/SQL编程也成了整个开发过程的一个重要组成部分。PL/SQL ...
发布Oracle存储过程包c#代码生成工具(CodeRobot) New Folder XCodeFactory3.0完全攻略--序 XCodeFactory3.0完全攻略--基本思想 XCodeFactory3.0完全攻略--简单示例 XCodeFactory3.0完全攻略--IDBAccesser ...
文件数据存储在Blob类型的FILE_CONTENT表字段上,在Spring中采用OracleLobHandler来处理Lob字段(包括Clob和Blob),由于在程序中不需要引用到oracle数据驱动程序的具体类且屏蔽了不同数据库处理Lob字段方法上的...
在SQLServer中分组时:不能以text,ntext,image类型的字段作为分组依据 在selecte统计函数中的字段,不能和普通的字段放在一起; 13、对数据库进行操作: 分离数据库: sp_detach_db; 附加数据库:sp_attach_db ...
在SQLServer中分组时:不能以text,ntext,image类型的字段作为分组依据 在selecte统计函数中的字段,不能和普通的字段放在一起; 13、对数据库进行操作: 分离数据库: sp_detach_db; 附加数据库:sp_attach_db 后...
在SQLServer中分组时:不能以text,ntext,image类型的字段作为分组依据 在selecte统计函数中的字段,不能和普通的字段放在一起; 13、对数据库进行操作: 分离数据库: sp_detach_db; 附加数据库:sp_attach_db 后...
其它打包类型 10.3. 通用生命周期目标 10.3.1. Process Resources 10.3.2. Compile 10.3.3. Process Test Resources 10.3.4. Test Compile 10.3.5. Test 10.3.6. Install 10.3.7. Deploy 11. 构建...
Closure表针对维度表计算distance,Closure表的生产参见例子中的存储过程sp_zycreateorgclosure 例如: 地区" uniqueMembers="true" nameColumn="ORGENTITYNAME" column="ORGENTITYID" parentColumn=...
//设置文件系统/tellinshare/sms的mind属性,否则当文件系统中有足够多的大文件(指32K以上的文件)时会出问题 #chfs -a options=rw,mind /tellinshare/sms mkgroup id=101 informix //创建组informix, 组编号101 ...