G
GipsyCN
Unregistered / Unconfirmed
GUEST, unregistred user!
请问下面的过程有没有语法错误?怎么编译不通过?
CREATE OR REPLACE PROCEDURE SP_AGGR_FEE
( AGGR_RESULT IN OUT PG_AGGR_DATASET.C_AGGR_DATASET,
DATE_FROM IN DATE,
DATE_TO IN DATE,
CustParam IN VARCHAR2,
FEE_RATE0 IN NUMBER,
FEE_RATE1 IN NUMBER,
FEE_RATE2 IN NUMBER,
FEE_RATE3 IN NUMBER,
FEE_RATE4 IN NUMBER,
REC_CNT OUT NUMBER,
TOTAL_FEE OUT NUMBER
) IS
CURSOR C_REGISTER IS
SELECT DISTINCT A_CarInfo.GSMVoiceNum,A_CarInfo.TruckId,A_Register.C_Name,A_Register.ContractNo,A_Register.BankName,
A_Register.BankNo,A_Register.Accounts,A_Register.ServiceCharge from A_Register,A_DriverInfo,A_CarInfo
WHERE A_CarInfo.DriverId=A_DriverInfo.DriverId AND
A_DriverInfo.TheName=A_Register.C_Name AND
A_DriverInfo.RegisterID=A_Register.RegisterID;
C_REGISTER_Rec C_REGISTER%ROWTYPE;
sSQL VARCHAR2(255);
Temstr VARCHAR2(255);
Temstr1 VARCHAR2(255);
Temstr2 VARCHAR2(255);
sRxTxSQL CONSTANT VARCHAR2(255) :='SELECT C_Name, ContractNo, GSMVoiceNum, TruckID, Bankname, ServiceCharge, Accounts FROM A_RxTx WHERE ';
Mysqlstr0 CONSTANT VARCHAR2(255) :='(CommandType = ''t'') AND (Describe LIKE ''发送点播信息%'') AND (Sender = ''通信中心'')AND (SendSource NOT LIKE ''%WebGIS服务中心%'')';
Mysqlstr1 CONSTANT VARCHAR2(255) :='(CommandType=''t'') and (Describe LIKE ''发送点播信息%'') and (Sender=''通信中心'') and (SendSource LIKE ''%WebGIS服务中心%'')';
Mysqlstr2 CONSTANT VARCHAR2(255) :='(CommandType = ''D'') AND (Describe LIKE ''询问位置%'')and(Sender = ''通信中心'') and (SendSource LIKE ''%WebGIS服务中心%'')';
Mysqlstr3 CONSTANT VARCHAR2(255) :='(CommandType = ''M'' OR CommandType = ''m'')AND(Receiver = ''通信中心'') AND (Describe LIKE ''%用户直接手机接入%'')';
Mysqlstr4 CONSTANT VARCHAR2(255) :='(Sender = ''通信中心'') AND (SendSource LIKE ''%用户手机%'')';
nmSum NUMBER(8,2);
type tyQryCur IS REF CURSOR;
curSubDataSet tyQryCur;
curSubDataSet_Rec curSubDataSet%ROWTYPE;
i INT;
FUNCTION GetHex(aStr IN CHAR)
RETURN NUMBER IS
BEGIN
IF (aStr = '1') or (aStr = '2') or (aStr = '3') or (aStr = '4') or
(aStr = '5') or (aStr = '6') or (aStr = '7') or (aStr = '8') or (aStr = '9') THEN
RETURN TO_NUMBER(aStr);
ELSIF (aStr = 'b') or (aStr = 'B') THEN
RETURN 11;
ELSIF (aStr = 'c') or (aStr = 'C') THEN
RETURN 12;
ELSIF (aStr = 'd') or (aStr = 'D') THEN
RETURN 13;
ELSIF (aStr = 'e') or (aStr = 'E') THEN
RETURN 14;
ELSIF (aStr = 'f') or (aStr = 'F') THEN
RETURN 15;
END IF;
END GetHex;
BEGIN
OPEN C_REGISTER;
REC_CNT := C_REGISTER%ROWCOUNT;
IF REC_CNT = 0 THEN
CLOSE C_REGISTER;
RETURN;
END IF;
TOTAL_FEE := 0;
LOOP
nmSum := 0;
FETCH C_REGISTER INTO C_REGISTER_Rec;
EXIT WHEN C_REGISTER%NOTFOUND;
Temstr1 := 'and Receiver='||C_REGISTER_Rec.GSMVoiceNum;
Temstr2 := ' AND (Content LIKE ''%*M*'||C_REGISTER_Rec.TruckID||'%)';
FOR i IN 0..4 LOOP
IF i = 0 THEN
sSQL := sRxTxSQL||Mysqlstr0||Temstr1;
ELSIF i = 1 THEN
sSQL := sRxTxSQL||Mysqlstr1||Temstr1;
ELSIF i = 2 THEN
sSQL := sRxTxSQL||Mysqlstr2||Temstr1;
ELSIF i = 3 THEN
sSQL := sRxTxSQL||Mysqlstr3||Temstr1;
ELSIF i = 4 THEN
sSQL := sRxTxSQL||Mysqlstr4||Temstr2;
END IF;
sSQL := sSQL||'and (SendTime >'||DATE_FROM||' and SendTime <'||DATE_TO||')';
OPEN curSubDataSet FOR sSQL;
IF i = 0 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE0;
ELSIF i = 1 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE1;
ELSIF i = 2 THEN
IF curSubDataSet%ROWCOUNT <> 0 THEN
LOOP
FETCH curSubDataSet INTO curSubDataSet_Rec;
EXIT WHEN curSubDataSet%NOTFOUND;
IF LENGTH(curSubDataSet_Rec.Content) = 9 THEN
Temstr := Copy(Content,3,2);
nmSum := nmSum + GetHex(Copy(Temstr,1,1))*16 + GetHex(Copy(Temstr,2,1));
END IF;
END LOOP;
END IF;
ELSIF i = 3 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE2;
ELSIF i = 4 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE3;
END IF;
CLOSE curSubDataSet;
nmSum := nmSum + C_REGISTER_Rec.ServiceCharge;
TOTAL_FEE := TOTAL_FEE + nmSum;
WHILE LENGTH(C_REGISTER_Rec.Accounts) < 21 LOOP
C_REGISTER_Rec.Accounts := C_REGISTER_Rec.Accounts||'0';
END LOOP;
Temstr := C_REGISTER_Rec.ContractNo||C_REGISTER_Rec.BankNo||C_REGISTER_Rec.Accounts;
INSERT INTO T_AGGR_FEE(CONTENT,FEE)
VALUES (Temstr,nmSum);
INSERT INTO A_ChargingTable(TruckId,C_Name,ContractNo,BankName,BankNo,Accounts,ServiceCharge,Money,ChargeDate,batch)
VALUES (C_REGISTER_Rec.TruckId,C_REGISTER_Rec.UserName,C_REGISTER_Rec.ContractNo,C_REGISTER_Rec.BankName,
C_REGISTER_Rec.BankNo,C_REGISTER_Rec.Accounts,C_REGISTER_Rec.ServiceCharge,
C_REGISTER_Rec.Sum,SYSDATE,CustParam);
ENDLOOP;--FOR i IN 0..4 LOOP
ENDLOOP;--Lookup Curssor C_REGISTER
CLOSE C_REGISTER;
END SP_AGGR_FEE;
CREATE OR REPLACE PROCEDURE SP_AGGR_FEE
( AGGR_RESULT IN OUT PG_AGGR_DATASET.C_AGGR_DATASET,
DATE_FROM IN DATE,
DATE_TO IN DATE,
CustParam IN VARCHAR2,
FEE_RATE0 IN NUMBER,
FEE_RATE1 IN NUMBER,
FEE_RATE2 IN NUMBER,
FEE_RATE3 IN NUMBER,
FEE_RATE4 IN NUMBER,
REC_CNT OUT NUMBER,
TOTAL_FEE OUT NUMBER
) IS
CURSOR C_REGISTER IS
SELECT DISTINCT A_CarInfo.GSMVoiceNum,A_CarInfo.TruckId,A_Register.C_Name,A_Register.ContractNo,A_Register.BankName,
A_Register.BankNo,A_Register.Accounts,A_Register.ServiceCharge from A_Register,A_DriverInfo,A_CarInfo
WHERE A_CarInfo.DriverId=A_DriverInfo.DriverId AND
A_DriverInfo.TheName=A_Register.C_Name AND
A_DriverInfo.RegisterID=A_Register.RegisterID;
C_REGISTER_Rec C_REGISTER%ROWTYPE;
sSQL VARCHAR2(255);
Temstr VARCHAR2(255);
Temstr1 VARCHAR2(255);
Temstr2 VARCHAR2(255);
sRxTxSQL CONSTANT VARCHAR2(255) :='SELECT C_Name, ContractNo, GSMVoiceNum, TruckID, Bankname, ServiceCharge, Accounts FROM A_RxTx WHERE ';
Mysqlstr0 CONSTANT VARCHAR2(255) :='(CommandType = ''t'') AND (Describe LIKE ''发送点播信息%'') AND (Sender = ''通信中心'')AND (SendSource NOT LIKE ''%WebGIS服务中心%'')';
Mysqlstr1 CONSTANT VARCHAR2(255) :='(CommandType=''t'') and (Describe LIKE ''发送点播信息%'') and (Sender=''通信中心'') and (SendSource LIKE ''%WebGIS服务中心%'')';
Mysqlstr2 CONSTANT VARCHAR2(255) :='(CommandType = ''D'') AND (Describe LIKE ''询问位置%'')and(Sender = ''通信中心'') and (SendSource LIKE ''%WebGIS服务中心%'')';
Mysqlstr3 CONSTANT VARCHAR2(255) :='(CommandType = ''M'' OR CommandType = ''m'')AND(Receiver = ''通信中心'') AND (Describe LIKE ''%用户直接手机接入%'')';
Mysqlstr4 CONSTANT VARCHAR2(255) :='(Sender = ''通信中心'') AND (SendSource LIKE ''%用户手机%'')';
nmSum NUMBER(8,2);
type tyQryCur IS REF CURSOR;
curSubDataSet tyQryCur;
curSubDataSet_Rec curSubDataSet%ROWTYPE;
i INT;
FUNCTION GetHex(aStr IN CHAR)
RETURN NUMBER IS
BEGIN
IF (aStr = '1') or (aStr = '2') or (aStr = '3') or (aStr = '4') or
(aStr = '5') or (aStr = '6') or (aStr = '7') or (aStr = '8') or (aStr = '9') THEN
RETURN TO_NUMBER(aStr);
ELSIF (aStr = 'b') or (aStr = 'B') THEN
RETURN 11;
ELSIF (aStr = 'c') or (aStr = 'C') THEN
RETURN 12;
ELSIF (aStr = 'd') or (aStr = 'D') THEN
RETURN 13;
ELSIF (aStr = 'e') or (aStr = 'E') THEN
RETURN 14;
ELSIF (aStr = 'f') or (aStr = 'F') THEN
RETURN 15;
END IF;
END GetHex;
BEGIN
OPEN C_REGISTER;
REC_CNT := C_REGISTER%ROWCOUNT;
IF REC_CNT = 0 THEN
CLOSE C_REGISTER;
RETURN;
END IF;
TOTAL_FEE := 0;
LOOP
nmSum := 0;
FETCH C_REGISTER INTO C_REGISTER_Rec;
EXIT WHEN C_REGISTER%NOTFOUND;
Temstr1 := 'and Receiver='||C_REGISTER_Rec.GSMVoiceNum;
Temstr2 := ' AND (Content LIKE ''%*M*'||C_REGISTER_Rec.TruckID||'%)';
FOR i IN 0..4 LOOP
IF i = 0 THEN
sSQL := sRxTxSQL||Mysqlstr0||Temstr1;
ELSIF i = 1 THEN
sSQL := sRxTxSQL||Mysqlstr1||Temstr1;
ELSIF i = 2 THEN
sSQL := sRxTxSQL||Mysqlstr2||Temstr1;
ELSIF i = 3 THEN
sSQL := sRxTxSQL||Mysqlstr3||Temstr1;
ELSIF i = 4 THEN
sSQL := sRxTxSQL||Mysqlstr4||Temstr2;
END IF;
sSQL := sSQL||'and (SendTime >'||DATE_FROM||' and SendTime <'||DATE_TO||')';
OPEN curSubDataSet FOR sSQL;
IF i = 0 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE0;
ELSIF i = 1 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE1;
ELSIF i = 2 THEN
IF curSubDataSet%ROWCOUNT <> 0 THEN
LOOP
FETCH curSubDataSet INTO curSubDataSet_Rec;
EXIT WHEN curSubDataSet%NOTFOUND;
IF LENGTH(curSubDataSet_Rec.Content) = 9 THEN
Temstr := Copy(Content,3,2);
nmSum := nmSum + GetHex(Copy(Temstr,1,1))*16 + GetHex(Copy(Temstr,2,1));
END IF;
END LOOP;
END IF;
ELSIF i = 3 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE2;
ELSIF i = 4 THEN
nmSum := nmSum + curSubDataSet%ROWCOUNT*FEE_RATE3;
END IF;
CLOSE curSubDataSet;
nmSum := nmSum + C_REGISTER_Rec.ServiceCharge;
TOTAL_FEE := TOTAL_FEE + nmSum;
WHILE LENGTH(C_REGISTER_Rec.Accounts) < 21 LOOP
C_REGISTER_Rec.Accounts := C_REGISTER_Rec.Accounts||'0';
END LOOP;
Temstr := C_REGISTER_Rec.ContractNo||C_REGISTER_Rec.BankNo||C_REGISTER_Rec.Accounts;
INSERT INTO T_AGGR_FEE(CONTENT,FEE)
VALUES (Temstr,nmSum);
INSERT INTO A_ChargingTable(TruckId,C_Name,ContractNo,BankName,BankNo,Accounts,ServiceCharge,Money,ChargeDate,batch)
VALUES (C_REGISTER_Rec.TruckId,C_REGISTER_Rec.UserName,C_REGISTER_Rec.ContractNo,C_REGISTER_Rec.BankName,
C_REGISTER_Rec.BankNo,C_REGISTER_Rec.Accounts,C_REGISTER_Rec.ServiceCharge,
C_REGISTER_Rec.Sum,SYSDATE,CustParam);
ENDLOOP;--FOR i IN 0..4 LOOP
ENDLOOP;--Lookup Curssor C_REGISTER
CLOSE C_REGISTER;
END SP_AGGR_FEE;