您好,登錄后才能下訂單哦!
本篇內容主要講解“怎么創建UNWRAP函數”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么創建UNWRAP函數”吧!
CREATE OR REPLACE PACKAGE AMOSUNWRAPPER IS FUNCTION DEFLATE(SRC IN VARCHAR2) RETURN RAW; FUNCTION DEFLATE(SRC IN VARCHAR2, QUALITY IN NUMBER) RETURN RAW; FUNCTION INFLATE(SRC IN RAW) RETURN VARCHAR2; END; / CREATE OR REPLACE PACKAGE BODY AMOSUNWRAPPER IS FUNCTION DEFLATE(SRC IN VARCHAR2) RETURN RAW IS BEGIN RETURN DEFLATE(SRC, 6); END; FUNCTION DEFLATE(SRC IN VARCHAR2, QUALITY IN NUMBER) RETURN RAW AS LANGUAGE JAVA NAME 'UNWRAPPER.Deflate( java.lang.String, int ) return byte[]'; FUNCTION INFLATE(SRC IN RAW) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'UNWRAPPER.Inflate( byte[] ) return java.lang.String'; END; / /* Formatted on2011/8/18 13:00:16 (QP5 v5.163.1008.3004) */ CREATE OR REPLACE JAVA SOURCE NAMED UNWRAPPER AS import java.io.*; import java.util.zip.*; public class UNWRAPPER { public static String Inflate(byte[] src) { try { ByteArrayInputStream bis = new ByteArrayInputStream(src); InflaterInputStream iis = new InflaterInputStream(bis); StringBuffer sb = new StringBuffer(); for(int c = iis.read(); c != -1; c = iis.read()) { sb.append((char)c); } return sb.toString(); } catch (Exception e) { } return null; } public static byte[] Deflate(String src, int quality) { try { byte[] tmp = new byte[src.length() + 100]; Deflater defl = new Deflater(quality); defl.setInput(src.getBytes("UTF-8")); defl.finish(); int cnt = defl.deflate(tmp); byte[] res = new byte[cnt ]; for(int i = 0; i < cnt; i++) res = tmp; return res; } catch (Exception e) { } return null; } } / ALTER JAVA SOURCE UNWRAPPER COMPILE / /* Formatted on2011/8/18 13:02:57 (QP5 v5.163.1008.3004) */ --為了輸出中文,要修改java過程 CREATE OR REPLACE JAVA SOURCE NAMED UNWRAPPER AS import java.io.*; import java.util.zip.*; public class UNWRAPPER { public static String Inflate(byte[] src) { try { ByteArrayInputStream bis = new ByteArrayInputStream( src ); InflaterInputStream iis = new InflaterInputStream( bis ); StringBuffer sb = new StringBuffer(); for(int c = iis.read(); c != -1; c = iis.read()) { sb.append((char) c); } String hello = new String(sb.toString().getBytes("iso8859-1"), "GBK"); return hello; } catch(Exception e) { } return null; } public static byte[] Deflate(String src, int quality) { try { byte[] tmp = new byte[src.length() + 100]; Deflater defl = new Deflater(quality); defl.setInput(src.getBytes("UTF-8")); defl.finish(); int cnt = defl.deflate(tmp); byte[] res = new byte[cnt]; for(int i = 0; i < cnt; i++) res = tmp; return res; } catch (Exception e) { } return null; } } / ALTER JAVA SOURCE UNWRAPPER COMPILE / /* Formatted on2011/8/18 13:00:41 (QP5 v5.163.1008.3004) */ CREATE OR REPLACE PROCEDURE UNWRAP(O IN VARCHAR, N IN VARCHAR, T IN VARCHAR) AS VWRAPPEDTEXT VARCHAR2(32767); VTRIMTEXT VARCHAR2(32767); VCHAR VARCHAR2(2); VREPCHAR VARCHAR2(2); VLZINFLATESTR VARCHAR2(32767); NLEN INTEGER; NLOOP INTEGER; NCNT INTEGER; CODE VARCHAR(512); BEGIN CODE := '3D6585B318DBE287F152AB634BB5A05F7D687B9B24C228678ADEA4261E03EB176F343E7A3FD2A96A0FE935561FB14D1078D975F6BC4104816106F9ADD6D5297E869E79E505BA84CC6E278EB05DA8F39FD0A271B858DD2C38994C480755E4538C46B62DA5AF322240DC50C3A1258B9C16605CCFFD0C981CD4376D3C3A30E86C3147F533DA43C8E35E1994ECE6A39514E09D64FA5915C52FCABB0BDFF297BF0A76B449445A1DF0009621807F1A82394FC1A7D70DD1D8FF139370EE5BEFBE09B97772E7B254B72AC7739066200E51EDF87C8F2EF412C62B83CDACCB3BC44EC069366202AE88FCAA4208A64557D39ABDE1238D924A1189746B91FBFEC901EA1BF7CE'; --sys.idltranslate表內容存到字符數組 VTRIMTEXT := ''; SELECT COUNT(*) INTO NCNT FROM DBA_SOURCE WHERE OWNER = O AND NAME = N AND TYPE = T; IF NCNT > 0 AND NCNT <= 5 THEN FOR I IN 1 .. NCNT LOOP IF I = 1 THEN SELECT RTRIM(SUBSTR(TEXT, INSTR(TEXT, CHR(10), 1, 20) + 1), CHR(10)) --保存去掉前邊20行的BASE64碼正文 INTO VLZINFLATESTR FROM DBA_SOURCE WHERE OWNER = O AND NAME = N AND TYPE = T AND LINE = I; ELSE SELECT TEXT INTO VLZINFLATESTR FROM DBA_SOURCE WHERE OWNER = O AND NAME = N AND TYPE = T AND LINE = I; END IF; VTRIMTEXT := VTRIMTEXT || VLZINFLATESTR; END LOOP; END IF; VTRIMTEXT := REPLACE(VTRIMTEXT, CHR(10), ''); NLEN := LENGTH(VTRIMTEXT) / 256; VWRAPPEDTEXT := ''; FOR I IN 0 .. NLEN LOOP --ifi< nLen then VWRAPPEDTEXT := VWRAPPEDTEXT || UTL_ENCODE.BASE64_DECODE(UTL_RAW.CAST_TO_RAW(SUBSTRB(VTRIMTEXT, 256 * I + 1, 256))); --else --vWrappedtext:=vWrappedtext||utl_encode.base64_decode(utl_raw.cast_to_raw(substrb(vtrimtext,64*i+1 ))) ; --endif; --DBMS_OUTPUT.PUT_LINE(vWrappedtext); END LOOP; --vWrappedtext:=substr(vWrappedtext,41); NLEN := LENGTH(VWRAPPEDTEXT) / 2 - 1; VLZINFLATESTR := ''; FOR NLOOP IN 20 .. NLEN LOOP --從第41字節開始 VCHAR := SUBSTRB(VWRAPPEDTEXT, NLOOP * 2 + 1, 2); VLZINFLATESTR := VLZINFLATESTR || SUBSTR(CODE, TO_NUMBER(VCHAR, 'XX') * 2 + 1, 2); --從字符串變量匹配 --DBMS_OUTPUT.PUT_LINE(vLZinflatestr); END LOOP; --DBMS_OUTPUT.PUT_LINE(vLZinflatestr); DBMS_OUTPUT.PUT_LINE(AMOSUNWRAPPER.INFLATE(VLZINFLATESTR)); END; /
exec unwrap('SYS','DBMS_ROWID','PACKAGE BODY'); select * from dba_source where name='DBMS_ROWID';
到此,相信大家對“怎么創建UNWRAP函數”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。