搜索
首页 电脑/网络 软件 系统软件

Oracle存储过程是怎样的?

Oracle存储过程是怎样的?

全部回答

2017-07-27

47 0
    第一个存储过程,属性串替换函数,常用于数据订正过程中(使用oracle提供的replace函数会有问题)create or replace function sp_replace_property_value(v_ch varchar2,v_from varchar2,v_to varchar2) return varchar2/*creator:danchencreate_time:2008-4-19function:replace taobao' property name and property value id as groupv_ch 属性串;v_from 源属性; v_to 目标属性,目标属性可为空,则变成删除属性*/as--定义返回的返回的属性字符串result_v varchar2(200):='';--定义剩余属性字符串变量temp_v varchar2(200):='';--定义分号位置fenhao_address number;--定义临时属性对变量v_pv varchar2(20); begin if v_ch is null or v_from is null then return 'error'; end if; if instr(v_ch,':') = 0 or instr(v_from,':')= 0 then return 'error'; end if; temp_v := v_ch; loop fenhao_address := instr(temp_v,';'); if fenhao_address=0 then --没有找到分号,则为最后一组属性名:属性值 v_pv := temp_v; --检查属性是否是要替换的属性 if v_pv != v_from then result_v := result_v||';'||v_pv ; else if v_to is not null then result_v := result_v||';'||v_to; end if; end if; --跳出循环 exit; else --取出属性对 v_pv := substr(temp_v,1,instr(temp_v,';')-1); --检查属性是否是要替换的属性 if v_pv != v_from then result_v := result_v||';'||v_pv ; else if v_to is not null then result_v := result_v||';'||v_to; end if; end if; --得到剩余的属性对 temp_v := substr(temp_v,instr(temp_v,';')+1); end if; end loop; --对结果进行处理,去掉最左侧的分号 if substr(result_v,1,1)=';' then result_v := substr(result_v,2); end if; --返回结果 return result_v;end sp_replace_property_value; 第一个存储过程使用示例: SQL> select sp_replace_property_value('33392:118167;33393:107054;33391:118167','33393:107054','') from dual; SP_REPLACE_PROPERTY_VALUE('33392:118167;33393:107054;33391:118167','33393:107054 -------------------------------------------------------------------------------- 33392:118167;33391:118167 SQL> select sp_replace_property_value('33392:118167;33393:107054;33391:118167','33393:107054','33393:100') from dual; SP_REPLACE_PROPERTY_VALUE('33392:118167;33393:107054;33391:118167','33393:107054 -------------------------------------------------------------------------------- 33392:118167;33393:100;33391:118167。
    。

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
系统软件
硬件
电脑装机
程序设计
互联网
操作系统/系统故障
笔记本电脑
反病毒
百度
软件
软件
系统软件
多媒体软件
办公软件
网络软件
图像处理软件
系统软件
系统软件
举报
举报原因(必选):
取消确定举报