create or replace procedure P_UpdateMissingParameters(
--输入参数
userOrderId in varchar2 , --用户订单ID
InResAttributeCode in varchar2 ,--资源属性编码
insertValue in varchar2 --用户输入的值
--输出参数
--InResTable out varchar2 ,--资源属性表
--InResTableColumn out varchar2--资源属性表字段
)
/***************************
author:[email protected]
date :2012-02-13
/***************************/
--定义常量
is icount number(8) not null;
product_id varchar2(50); --产品ID
net_type_code varchar2(50); --连接方式
in_res_table varchar2(50); --资源属性表名称
in_res_table_pk varchar2(50); --资源属性表主键
in_res_table_column varchar(50); --资源属性表字段
in_busi_res_kind_code varchar2(50); --业务资源种类编码
-- fcount number(8) not null;
resCount number(8) not null;
resId varchar2(20); --业务资源ID
resKindCount number(8) not null;
atom_res_kind_code varchar2(20); --原子资源种类
shebeiId varchar2(20); --连接端口设备ID
duanziId varchar2(20); --连接端子ID
cableId varchar2(20); --连接光缆的ID
pairId varchar2(20); --连接纤芯的ID
luojiId varchar2(20); --逻辑号码ID
wuliID varchar2(20); --物理号码ID
begin
--通过用户订单ID查询用户订单表中是否有这条记录
/* select count(*) into fcount from rt_userorder_info ri where ri.user_order_id=userOrderId;
if fcount is null then
fcount:=0;
end if;*/ --根据输入参数用户订单ID统计多少条记录
select count(*) into icount from rt_userorder_info ri where ri.user_order_id=userOrderId; if icount=1 then
--如果通过用户订单ID统计只有一条记录则 查询出产品ID和连接方式
select ri.product_id,ri.net_type_id into product_id,net_type_code from rt_userorder_info ri where ri.user_order_id=userOrderId; --通过产品ID和连接方式查询出 资源属性表名称、资源属性表主键、资源属性表字段、业务资源种类编码
select rd.in_res_table,
rd.in_res_table_pk,
rd.in_res_table_column,
in_res_kind_code
into in_res_table,
in_res_table_pk,
in_res_table_column,
in_busi_res_kind_code
from rt_resreturnconfig_dict rd
where rd.product_id = product_id
and rd.net_type_code = net_type_code
and rd.in_res_attribute_code = InResAttributeCode;
dbms_output.put_line('更新前资源属性表名称:'||in_res_table);
dbms_output.put_line('更新钱资源属性表主键:'||in_res_table_pk);
dbms_output.put_line('更新前资源属性表字段:'||in_res_table_column);
dbms_output.put_line('更新前业务资源种类编码:'||in_busi_res_kind_code);
elsif icount>1 then
--如果通过用户订单ID统计的总数大于或者等于2条以上记录
dbms_output.put_line('TOO_MANY_ROWS:一个用户订单ID对应只有一条记录,请核对!');
else
dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!'); end if;
--根据用户订单ID和业务资源种类编码判断是否有记录
select count(*)
into resCount
from rt_workres_info rw
where rw.user_order_id = userOrderId
and rw.res_kind_code = in_busi_res_kind_code; if resCount=1 then
--根据用户订单ID和业务资源种类编码查询出业务资源ID (res_id)
select res_id
into resId
from rt_workres_info rw
where rw.user_order_id = userOrderId
and rw.res_kind_code = in_busi_res_kind_code;
dbms_output.put_line('更新前业务资源ID:'||resID); elsif resCount>1 then
--如果通过用户订单ID和业务资源种类编码统计的总数大于或者等于2条以上记录
dbms_output.put_line('TOO_MANY_ROWS:通过用户订单ID和业务资源种类编码过滤出业务资源ID应该只有一条记录,请核对!'); else dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!');
end if; --根据业务资源ID查找工单原子资源表判断是否有记录
select count(*) into resKindCount from rt_WorkAtomRes_info rwi where rwi.res_id=resId; if resKindCount=1 then
--根据业务资源ID查找工单原子资源表中(原子资源种类编码)
select rwi.atom_res_kind_code into atom_res_kind_code from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前业原子资源种类编码:'||atom_res_kind_code); elsif resKindCount>1 then
--如果通过业务资源ID统计的总数大于或者等于2条以上的记录
dbms_output.put_line('TOO_MANY_ROWS:通过业务资源ID过滤出应该只有一条记录,请核对!'); else dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!'); --根据原子资源种类表中编码 判断value1存放的值是端口或者是缆线
--atom_res_kind_code=10 value1为端口(连接设备ID) value2为端子
if atom_res_kind_code=10 then
--如果原子资源种类编码为10 则根据业务资源ID找出value1:连接端口设备ID,value2:连接端子ID
select rwi.value1,rwi.value2 into shebeiId,duanziId from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前连接端口设备ID:'||shebeiID||'-------'||'||更新前连接端子ID:'||duanziId);
--根据设备ID 更新对应的哪张表的 哪一列的字段值。
if in_res_table='RT_PORT_INFO ' then
--如果从资源反馈配置表中查询对应的表为RT_PORT_INFO(端口信息表) 则根据端子ID 更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=duanziId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column||'----'||'更新后的资源属性表字段值value:'||insertValue);
commit;
else
--如果从资源反馈配置表中查询对应的表为RT_DEVICE_INFO、RT_DEVICEONU_INFO(设备信息表、ONU表) 则根据设备ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=shebeiId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column||'----'||'更新后的资源属性表字段值value:'||insertValue);
commit;
end if;
elsif atom_res_kind_code=20 then
--如果原子资源种类表面吗为20 则根据业务资源ID找出value1:连接缆线ID,value2:连接纤芯ID
select rwi.value1,rwi.value2 into cableId,pairId from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前连接缆线ID:'||cableId||'--------'||'更新钱连接纤芯ID:'||pairId);
--根据缆线ID 更新对应的哪张表的 哪一列的字段值
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=cableId;
dbms_output.put_line('资源种类编码=20(缆线线序)更新后的资源属性表字段值value:'||insertValue);
commit; elsif atom_res_kind_code=30 then
--如果原子资源种类编码为30 则根据业务资源ID 找出value1对应的逻辑号码ID
select rwi.value1 into luojiId from rt_workatomres_info rwi where rwi.res_id=resId;
--根据逻辑号码ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=luojiId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column);
dbms_output.put_line('资源种类编码=30(逻辑号码)更新后的资源属性表字段值value:'||insertValue);
commit;
elsif atom_res_kind_code=40 then
--如果原子资源种类编码为40 则根据业务资源ID找出value1对应的物理号码ID
select rwi.value1 into wuliId from rt_workatomres_info rwi where rwi.res_id=resId;
--根据物理号码ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=wuliId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column);
dbms_output.put_line('资源种类编码=40(物理号码)更新后的资源属性表字段值value:'||insertValue);
commit;
--特殊情况处理:处理存在默认值的情况。这类情况不同处理。
else
dbms_output.put_line('这种情况什么都不处理!');
end if; end P_UpdateMissingParameters;
报错信息如下:
PROCEDURE IRMS_HTB1.P_UPDATEMISSINGPARAMETERS 编译错误错误:PLS-00103: 出现符号 "P_UPDATEMISSINGPARAMETERS"在需要下列之一时:
if
行:184
文本:end P_UpdateMissingParameters;
--输入参数
userOrderId in varchar2 , --用户订单ID
InResAttributeCode in varchar2 ,--资源属性编码
insertValue in varchar2 --用户输入的值
--输出参数
--InResTable out varchar2 ,--资源属性表
--InResTableColumn out varchar2--资源属性表字段
)
/***************************
author:[email protected]
date :2012-02-13
/***************************/
--定义常量
is icount number(8) not null;
product_id varchar2(50); --产品ID
net_type_code varchar2(50); --连接方式
in_res_table varchar2(50); --资源属性表名称
in_res_table_pk varchar2(50); --资源属性表主键
in_res_table_column varchar(50); --资源属性表字段
in_busi_res_kind_code varchar2(50); --业务资源种类编码
-- fcount number(8) not null;
resCount number(8) not null;
resId varchar2(20); --业务资源ID
resKindCount number(8) not null;
atom_res_kind_code varchar2(20); --原子资源种类
shebeiId varchar2(20); --连接端口设备ID
duanziId varchar2(20); --连接端子ID
cableId varchar2(20); --连接光缆的ID
pairId varchar2(20); --连接纤芯的ID
luojiId varchar2(20); --逻辑号码ID
wuliID varchar2(20); --物理号码ID
begin
--通过用户订单ID查询用户订单表中是否有这条记录
/* select count(*) into fcount from rt_userorder_info ri where ri.user_order_id=userOrderId;
if fcount is null then
fcount:=0;
end if;*/ --根据输入参数用户订单ID统计多少条记录
select count(*) into icount from rt_userorder_info ri where ri.user_order_id=userOrderId; if icount=1 then
--如果通过用户订单ID统计只有一条记录则 查询出产品ID和连接方式
select ri.product_id,ri.net_type_id into product_id,net_type_code from rt_userorder_info ri where ri.user_order_id=userOrderId; --通过产品ID和连接方式查询出 资源属性表名称、资源属性表主键、资源属性表字段、业务资源种类编码
select rd.in_res_table,
rd.in_res_table_pk,
rd.in_res_table_column,
in_res_kind_code
into in_res_table,
in_res_table_pk,
in_res_table_column,
in_busi_res_kind_code
from rt_resreturnconfig_dict rd
where rd.product_id = product_id
and rd.net_type_code = net_type_code
and rd.in_res_attribute_code = InResAttributeCode;
dbms_output.put_line('更新前资源属性表名称:'||in_res_table);
dbms_output.put_line('更新钱资源属性表主键:'||in_res_table_pk);
dbms_output.put_line('更新前资源属性表字段:'||in_res_table_column);
dbms_output.put_line('更新前业务资源种类编码:'||in_busi_res_kind_code);
elsif icount>1 then
--如果通过用户订单ID统计的总数大于或者等于2条以上记录
dbms_output.put_line('TOO_MANY_ROWS:一个用户订单ID对应只有一条记录,请核对!');
else
dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!'); end if;
--根据用户订单ID和业务资源种类编码判断是否有记录
select count(*)
into resCount
from rt_workres_info rw
where rw.user_order_id = userOrderId
and rw.res_kind_code = in_busi_res_kind_code; if resCount=1 then
--根据用户订单ID和业务资源种类编码查询出业务资源ID (res_id)
select res_id
into resId
from rt_workres_info rw
where rw.user_order_id = userOrderId
and rw.res_kind_code = in_busi_res_kind_code;
dbms_output.put_line('更新前业务资源ID:'||resID); elsif resCount>1 then
--如果通过用户订单ID和业务资源种类编码统计的总数大于或者等于2条以上记录
dbms_output.put_line('TOO_MANY_ROWS:通过用户订单ID和业务资源种类编码过滤出业务资源ID应该只有一条记录,请核对!'); else dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!');
end if; --根据业务资源ID查找工单原子资源表判断是否有记录
select count(*) into resKindCount from rt_WorkAtomRes_info rwi where rwi.res_id=resId; if resKindCount=1 then
--根据业务资源ID查找工单原子资源表中(原子资源种类编码)
select rwi.atom_res_kind_code into atom_res_kind_code from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前业原子资源种类编码:'||atom_res_kind_code); elsif resKindCount>1 then
--如果通过业务资源ID统计的总数大于或者等于2条以上的记录
dbms_output.put_line('TOO_MANY_ROWS:通过业务资源ID过滤出应该只有一条记录,请核对!'); else dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!'); --根据原子资源种类表中编码 判断value1存放的值是端口或者是缆线
--atom_res_kind_code=10 value1为端口(连接设备ID) value2为端子
if atom_res_kind_code=10 then
--如果原子资源种类编码为10 则根据业务资源ID找出value1:连接端口设备ID,value2:连接端子ID
select rwi.value1,rwi.value2 into shebeiId,duanziId from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前连接端口设备ID:'||shebeiID||'-------'||'||更新前连接端子ID:'||duanziId);
--根据设备ID 更新对应的哪张表的 哪一列的字段值。
if in_res_table='RT_PORT_INFO ' then
--如果从资源反馈配置表中查询对应的表为RT_PORT_INFO(端口信息表) 则根据端子ID 更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=duanziId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column||'----'||'更新后的资源属性表字段值value:'||insertValue);
commit;
else
--如果从资源反馈配置表中查询对应的表为RT_DEVICE_INFO、RT_DEVICEONU_INFO(设备信息表、ONU表) 则根据设备ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=shebeiId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column||'----'||'更新后的资源属性表字段值value:'||insertValue);
commit;
end if;
elsif atom_res_kind_code=20 then
--如果原子资源种类表面吗为20 则根据业务资源ID找出value1:连接缆线ID,value2:连接纤芯ID
select rwi.value1,rwi.value2 into cableId,pairId from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前连接缆线ID:'||cableId||'--------'||'更新钱连接纤芯ID:'||pairId);
--根据缆线ID 更新对应的哪张表的 哪一列的字段值
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=cableId;
dbms_output.put_line('资源种类编码=20(缆线线序)更新后的资源属性表字段值value:'||insertValue);
commit; elsif atom_res_kind_code=30 then
--如果原子资源种类编码为30 则根据业务资源ID 找出value1对应的逻辑号码ID
select rwi.value1 into luojiId from rt_workatomres_info rwi where rwi.res_id=resId;
--根据逻辑号码ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=luojiId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column);
dbms_output.put_line('资源种类编码=30(逻辑号码)更新后的资源属性表字段值value:'||insertValue);
commit;
elsif atom_res_kind_code=40 then
--如果原子资源种类编码为40 则根据业务资源ID找出value1对应的物理号码ID
select rwi.value1 into wuliId from rt_workatomres_info rwi where rwi.res_id=resId;
--根据物理号码ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=wuliId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column);
dbms_output.put_line('资源种类编码=40(物理号码)更新后的资源属性表字段值value:'||insertValue);
commit;
--特殊情况处理:处理存在默认值的情况。这类情况不同处理。
else
dbms_output.put_line('这种情况什么都不处理!');
end if; end P_UpdateMissingParameters;
报错信息如下:
PROCEDURE IRMS_HTB1.P_UPDATEMISSINGPARAMETERS 编译错误错误:PLS-00103: 出现符号 "P_UPDATEMISSINGPARAMETERS"在需要下列之一时:
if
行:184
文本:end P_UpdateMissingParameters;
解决方案 »
- 头大了,帮忙看看这个四表连接查询的最简便的写法。
- ?执行SQL根据语句时出现JS错误
- 怎样实现2台pc机(双网卡,单普通硬盘,windows2003下)的oracle的群集?
- 如何用SELECT语句检索四个表
- oracle 的new_time函数自动实现了对夏令时的计算么?
- 启动SQL*Plus时说没有监听器
- 高分求教oracle8.1.7中exp/imp中的容量问题
- 写触发器时如何更新其他实例的表?
- 怎么办?启动OMS服务时出现内存不能 read 错误!
- 不同服务器的两个实例,相同字符集,一个导出,一个导入。导入时却发生“ORA-12899: 列XXX的值太大 (实际值: 39, 最大值: 32)”的报错
- Oracle连接Ora-12547:TNS:丢失连接
- 关于oracle包失效问题
--如果原子资源种类表面吗为20 则根据业务资源ID找出value1:连接缆线ID,value2:连接纤芯ID
select rwi.value1,rwi.value2 into cableId,pairId from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前连接缆线ID:'||cableId||'--------'||'更新钱连接纤芯ID:'||pairId);
--根据缆线ID 更新对应的哪张表的 哪一列的字段值
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=cableId;
dbms_output.put_line('资源种类编码=20(缆线线序)更新后的资源属性表字段值value:'||insertValue);
commit; elsif atom_res_kind_code=30 then
--如果原子资源种类编码为30 则根据业务资源ID 找出value1对应的逻辑号码ID
select rwi.value1 into luojiId from rt_workatomres_info rwi where rwi.res_id=resId;
--根据逻辑号码ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=luojiId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column);
dbms_output.put_line('资源种类编码=30(逻辑号码)更新后的资源属性表字段值value:'||insertValue);
commit;
elsif atom_res_kind_code=40 then
--如果原子资源种类编码为40 则根据业务资源ID找出value1对应的物理号码ID
select rwi.value1 into wuliId from rt_workatomres_info rwi where rwi.res_id=resId;
--根据物理号码ID更新记录
update in_res_table set in_res_table_column=insertValue where in_res_table_pk=wuliId;
dbms_output.put_line('更新后资源属性表为:'||in_res_table||'--------'||'更新后的资源属性表字段key:'||in_res_table_column);
dbms_output.put_line('资源种类编码=40(物理号码)更新后的资源属性表字段值value:'||insertValue);
commit;
这里错了。elsif 你写错了。
而elsif是黑色的
--根据业务资源ID查找工单原子资源表判断是否有记录
select count(*) into resKindCount from rt_WorkAtomRes_info rwi where rwi.res_id=resId; if resKindCount=1 then
--根据业务资源ID查找工单原子资源表中(原子资源种类编码)
select rwi.atom_res_kind_code into atom_res_kind_code from rt_workatomres_info rwi where rwi.res_id=resId;
dbms_output.put_line('更新前业原子资源种类编码:'||atom_res_kind_code); else if resKindCount>1 then
--如果通过业务资源ID统计的总数大于或者等于2条以上的记录
dbms_output.put_line('TOO_MANY_ROWS:通过业务资源ID过滤出应该只有一条记录,请核对!'); else dbms_output.put_line('NO_DATA_FOUND:没有找到合法的数据!');
===============================================================================
加个 end if;