CREATE OR REPLACE PACKAGE BODY EBS_TRADE IS
-- 获取数据库中的错误信息
PROCEDURE MakeErrorMessage(Head IN EbsHeadObject, ErrorCode IN VARCHAR2,
ResBuffer OUT VARCHAR2)
AS
PRAGMA AUTONOMOUS_TRANSACTION;
time_end NUMBER;
BEGIN
time_end:=DBMS_UTILITY.GET_TIME;
UPDATE BASE_STREAM_LOG SET STATE = 1,RETCODE=ErrorCode,ELAPSED=(time_end-Head.time_begin) WHERE STREAMID = Head.StreamId;
-- 这个是内部事务,进行提交
COMMIT;
SELECT LPAD(Head.serno,13,'0') || RETCODE || RETMESSAGE INTO ResBuffer FROM BASE_RET_INFO
WHERE RETCODE = ErrorCode;
EXCEPTION
WHEN NO_DATA_FOUND THEN
ResBuffer := LPAD(Head.serno,13,'0') ||ErrorCode || '未知错误代码';
END MakeErrorMessage;
PROCEDURE MakeCancelMessage(Head IN EbsHeadObject, ErrorCode IN VARCHAR2,
ResBuffer IN VARCHAR2)
AS
PRAGMA AUTONOMOUS_TRANSACTION;
time_end NUMBER;
BEGIN
time_end:=DBMS_UTILITY.GET_TIME;
UPDATE BASE_STREAM_LOG SET STATE = 1,RETCODE=ErrorCode,ELAPSED=(time_end-Head.time_begin) WHERE STREAMID = Head.StreamId;
-- 这个是内部事务,进行提交
COMMIT;
--SELECT LPAD(Head.serno,13,'0') || RETCODE || RETMESSAGE INTO ResBuffer FROM BASE_RET_INFO
--
WHERE RETCODE = ErrorCode;
EXCEPTION
WHEN NO_DATA_FOUND THEN
--ResBuffer := LPAD(Head.serno,13,'0') ||ErrorCode || '未知错误代码';
ROLLBACK;
RETURN;
END MakeCancelMessage;
PROCEDURE WriteElapsed(Head IN EbsHeadObject)
AS
PRAGMA AUTONOMOUS_TRANSACTION;
time_end NUMBER;
BEGIN
time_end:=DBMS_UTILITY.GET_TIME;
UPDATE BASE_STREAM_LOG SET ELAPSED=(time_end-Head.time_begin)||'毫秒' WHERE STREAMID = Head.StreamId;
-- 这个是内部事务,进行提交
COMMIT;
END WriteElapsed;
PROCEDURE PrintLogInfo(Head IN EBSHEADOBJECT, Info IN VARCHAR2)
AS
FileHandle UTL_FILE.file_type;
HeadInfo VARCHAR(2000);
BEGIN
FileHandle := UTL_FILE.fopen('FILESERVERDIR','PrintLogInfo.dbg', 'a', 2000);
HeadInfo := '[交易' || Head.TradeType || Head.TradeCode
|| '][会话' || sys_context('USERENV', 'SESSIONID')
|| '][时间'|| to_char(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') || ']';
UTL_FILE.put_line(FileHandle, HeadInfo);
UTL_FILE.put_line(FileHandle, ' ' || Info);
UTL_FILE.fflush(FileHandle);
UTL_FILE.fclose(FileHandle);
END PrintLogInfo;
FUNCTION EncryptPassword6(iOldPass IN VARCHAR2) RETURN VARCHAR2 IS
Result VARCHAR2(6);
Temp VARCHAR2(6);
c CHAR(1);
c1 CHAR(1);
c2 CHAR(1);
c3 CHAR(1);
c4 CHAR(1);
c5 CHAR(1);
c6 CHAR(1);
BEGIN
IF LENGTHB(iOldPass) < 6 THEN
Temp := LPAD(iOldPass, 6, '0');
ELSIF LENGTHB(iOldPass) > 6 THEN
Temp := SUBSTRB(iOldPass, 1, 6);
ELSE
Temp := iOldPass;
END IF;
c := SUBSTRB(Temp, 5, 1);
IF c = '0' THEN
c1 := '0';
ELSE
c1 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 4, 1);
IF c = '0' THEN
c2 := '0';
ELSE
c2 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 1, 1);
IF c = '0' THEN
c3 := '0';
ELSE
c3 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 6, 1);
IF c = '0' THEN
c4 := '0';
ELSE
c4 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 3, 1);
IF c = '0' THEN
c5 := '0';
ELSE
c5 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 2, 1);
IF c = '0' THEN
c6 := '0';
ELSE
c6 := CHR(106 - ASCII(c));
END IF;
Result := c1 || c2 || c3 || c4 || c5 || c6;
RETURN Result;
END EncryptPassword6;
-- 加密密码
FUNCTION EncryptPassword(iOldPass IN VARCHAR2) RETURN VARCHAR2 IS
Result VARCHAR2(8);
Temp VARCHAR2(8);
c CHAR(1);
c1 CHAR(1);
c2 CHAR(1);
c3 CHAR(1);
c4 CHAR(1);
c5 CHAR(1);
c6 CHAR(1);
C7 CHAR(1);
C8 CHAR(1);
BEGIN
IF LENGTHB(iOldPass) < 8 THEN
Temp := LPAD(iOldPass, 8, '0');
ELSIF LENGTHB(iOldPass) > 8 THEN
Temp := SUBSTRB(iOldPass, 1, 8);
ELSE
Temp := iOldPass;
END IF;
c := SUBSTRB(Temp, 5, 1);
IF c = '0' THEN
c1 := '0';
ELSE
c1 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 4, 1);
IF c = '0' THEN
c2 := '0';
ELSE
c2 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 1, 1);
IF c = '0' THEN
c3 := '0';
ELSE
c3 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 6, 1);
IF c = '0' THEN
c4 := '0';
ELSE
c4 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 3, 1);
IF c = '0' THEN
c5 := '0';
ELSE
c5 :=CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 2, 1);
IF c = '0' THEN
c6 := '0';
ELSE
c6 := CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 7, 1);
IF c = '0' THEN
c7 := '0';
ELSE
c7 := CHR(106 - ASCII(c));
END IF;
c := SUBSTRB(Temp, 8, 1);
IF c = '0' THEN
c8 := '0';
ELSE
c8 := CHR(106 - ASCII(c));
END IF;
Result := c1 || c2 || c3 || c4 || c5 || c6 || c7 || c8 ;
RETURN Result;
END EncryptPassword;
/*生成随机数*/
FUNCTION GetRandNum RETURN NUMBER
IS
ResultNumber NUMBER(6);
BEGIN
ResultNumber := CEIL(DBMS_RANDOM.VALUE() * 1000000);
IF ResultNumber < 100000 THEN
ResultNumber := ResultNumber + 100000;
END IF;
RETURN ResultNumber;
END GetRandNum;
-- 加密授权码
FUNCTION EncryptAuth(
iAuthCode IN VARCHAR2, iHdCode IN VARCHAR2) RETURN VARCHAR2
AS
AuthCode2 VARCHAR2(6);
SoundChar VARCHAR2(32);
TransChar VARCHAR2(32);
BEGIN
AuthCode2 := EBS_TRADE.EncryptPassword6(iAuthCode);
SoundChar := SOUNDEX(iHdcode);
TransChar := TRANSLATE(iHdcode, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'0123456789');
RETURN SoundChar || substr(iHdCode, 1, 3) || AuthCode2|| TransChar;
END EncryptAuth;
END;
**********本博客所有内容均为原创,如有转载请注明作者和出处!!!**********
Name: guoyJoe
QQ: 252803295
Email: [email protected]
Blog: http://blog.csdn.net/guoyJoe
ITPUB: http://www.itpub.net/space-uid-28460966.html
OCM: http://education.oracle.com/education/otn/YGuo.HTM
_____________________________________________________________
加群验证问题:哪些SGA结构是必需的,哪些是可选的?否则拒绝申请!!!
答案在:http://blog.csdn.net/guoyjoe/article/details/8624392
Oracle@Paradise 总群:127149411
Oracle@Paradise No.1群:177089463(已满)
Oracle@Paradise No.2群:121341761
Oracle@Paradise No.3群:140856036