Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create UNWRAP function

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to create UNWRAP functions", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to create a UNWRAP function.

Create UNWRAP function 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 UNWRAPPERASimport 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 UNWRAPPERASimport 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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report