日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Oracle數據庫存儲過程 ,去除給定字符串中重復的

系統 2076 0
以下函數是本人在編寫Oracle數據庫存儲過程時寫的函數,覺得該函數通用性較強,因此發表出來供需要的人參考.

這個函數的功能主要是用于去除給定字符串中重復的字符串.在使用中需要指定字符串的分隔符.示例:
str := MyReplace('13,14,13,444', ',');
輸出:
13,14,444

create or replace function MyReplace(oldStr varchar2, sign varchar2) return varchar2 is
? str varchar2(1000);
? currentIndex number;
? startIndex number;
? endIndex number;

? type str_type is table of varchar2(30)
?????? index by binary_integer;
? arr str_type;

? Result varchar2(1000);
begin????
? if oldStr is null then
??? return ('');
? end if;
?
? str := oldStr;
?
? currentIndex := 0;
? startIndex := 0;
? loop
??? currentIndex := currentIndex + 1;
??? endIndex := instr(str, sign, 1, currentIndex);
??? if (endIndex <= 0) then
????? exit;
? end if;
???
? arr(currentIndex) := trim(substr(str, startIndex + 1, endIndex - startIndex - 1));
? startIndex := endIndex;
? end loop;
?
? --取最后一個字符串
? arr(currentIndex) := substr(str, startIndex + 1, length(str));
?
? --去掉重復出現的字符串
? for i in 1.. currentIndex - 1 loop
? for j in i + 1..currentIndex loop
??? if arr(i) = arr(j) then
????? arr(j) := '';
??? end if;
? end loop;
? end loop;

? str := '';
? for i in 1..currentIndex loop
? if arr(i) is not null then
??? str := str || sign || arr(i);
???
??? --數組置空
??? arr(i) := '';
? end if;
? end loop;
?
? --去掉前面的標識符
? Result := substr(str, 2, length(str));
? return(Result);
end MyReplace;?
?

Oracle數據庫存儲過程 ,去除給定字符串中重復的字符串


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 阜城县| 方城县| 金华市| 贵阳市| 长白| 闽侯县| 临城县| 武夷山市| 惠州市| 永昌县| 鄂托克前旗| 蓬安县| 中西区| 阳泉市| 宁河县| 衡水市| 新乐市| 安仁县| 乳山市| 沙坪坝区| 泰安市| 昭觉县| 乌拉特中旗| 正宁县| 特克斯县| 温泉县| 格尔木市| 洪雅县| 甘泉县| 梅州市| 上饶市| 望奎县| 建水县| 金川县| 临泽县| 宁南县| 门头沟区| 密云县| 南澳县| 泽库县| 北安市|