我正在尝试从我的spring项目中调用存储过程。此存储过程尝试在表中插入一些值,如果无法插入数据,则返回一些字符串。例如银行代码和存款单不存在
Dao class
@Repository
public class PaymentDaoImpl implements PaymentDao {
@Autowired
private SessionFactory sessionFactory;
private Session session;
private Transaction trans;
DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy ");
Date date = new Date();
public void savePayments(PaymentParams paymentParams) {
try {
session = sessionFactory.openSession();
trans = session.beginTransaction();
System.out.println("date format");
System.out.println(dateFormat.format(date));
Query<Object[]> query = session.createNativeQuery
("CALLPROC_INS_RMIS_BNK_VCHER_TABLE
(:P_BUD_YEAR,:P_DISTRICT_CODE,:P_TRAN_NDATE,:P_TRAN_EDATE,:P_BANK_CODE,
:P_DEPOSIT_BANK_CODE,:P_PO_CODE,:P_ECONOMIC_CODE5,:P_AMOUNT,:P_PAN,
:P_PAYEE_NAME,:P_PAYEE_ADD,:P_PHONE_NO,:P_TAX_YEAR,:P_PAYMENT_TYPE,:P_CHEQUE_DRAFT_NO,
:P_DATETIME,:P_CREATED_BY,:P_TAX_FLAG,:P_CLEARANCE_EDATE,:P_CLEARANCE_NDATE,
:P_VOUCHER_NO,:P_CHEQUE_TYPE,:P_CHE_DRA_ISSUE_BANK,
:P_VOUCHER_STATUS,:P_RECORD_LOCK_FLAG,:P_VOUCHER_DATE,:P_ADJUST_FLAG,
:P_VOUCHER_NDATE,:P_DEPOSIT_SLIP_NO,:P_COUNTER_CODE,:P_UPDATE_DATETIME,
:P_UPDATE_BY,:P_PO_AMDANI_FLAG,:P_DOLLAR_AMOUNT,:P_UPDATE_NDATE,
:P_DEPOSIT_SLIP_AUTO,:P_TRAN_BUD_YEAR,:p_error_code)")
.setParameter("P_BUD_YEAR", "2071/72")
.setParameter("P_DISTRICT_CODE", "28")
.setParameter("P_TRAN_NDATE", "2071-04-01")
.setParameter("P_TRAN_EDATE", dateFormat.format(date))
.setParameter("P_BANK_CODE", "11001016") //5
.setParameter("P_DEPOSIT_BANK_CODE", "11001016")
.setParameter("P_PO_CODE", "28-204-02") //7
.setParameter("P_ECONOMIC_CODE5", "14221")
.setParameter("P_AMOUNT", 132)
.setParameter("P_PAN", null)
.setParameter("P_PAYEE_NAME", "पुनरावेदन अदा")
.setParameter("P_PAYEE_ADD", "Patan")
.setParameter("P_PHONE_NO", "553658")
.setParameter("P_TAX_YEAR", "2071/72")
.setParameter("P_PAYMENT_TYPE", "A")
.setParameter("P_CHEQUE_DRAFT_NO", null)
.setParameter("P_DATETIME", dateFormat.format(date))
.setParameter("P_CREATED_BY", "GBL001")
.setParameter("P_TAX_FLAG", "N")
.setParameter("P_CLEARANCE_EDATE", dateFormat.format(date))
.setParameter("P_CLEARANCE_NDATE", "2071-04-01")
.setParameter("P_VOUCHER_NO", "00000001")
.setParameter("P_CHEQUE_TYPE", null)
.setParameter("P_CHE_DRA_ISSUE_BANK", null)
.setParameter("P_VOUCHER_STATUS", "T")
.setParameter("P_RECORD_LOCK_FLAG", "Y")
.setParameter("P_VOUCHER_DATE", dateFormat.format(date))
.setParameter("P_ADJUST_FLAG", "N")
.setParameter("P_VOUCHER_NDATE", "2071-04-01")
.setParameter("P_DEPOSIT_SLIP_NO", 25764132)
.setParameter("P_COUNTER_CODE", "P3")
.setParameter("P_UPDATE_DATETIME", dateFormat.format(date))
.setParameter("P_UPDATE_BY", "D00265")
.setParameter("P_PO_AMDANI_FLAG", "Y")
.setParameter("P_DOLLAR_AMOUNT", 0)
.setParameter("P_UPDATE_NDATE", "2073-04-03")
.setParameter("P_DEPOSIT_SLIP_AUTO", "N")
.setParameter("P_TRAN_BUD_YEAR", "2073/74")
.setParameter("p_error_code", null);
List<Object[]> list = query.getResultList();
for (Object[] obj : list) {
System.out.println("result" + obj[0]);
}
}catch (Exception e){
e.printStackTrace();
}
}
}
查询执行存储过程:
目前,在sql开发人员执行时,此存储过程无法插入数据,因此返回文本“银行代码和存款单不存在”。我需要准确地获取此返回的文本。
DECLARE
v_error_code VARCHAR2 (250);
v_voucher_no VARCHAR2 (250);
BEGIN
RMIS7172.PROC_INS_RMIS_BNK_VCHER_TABLE (
P_BUD_YEAR => '2071/72',
P_DISTRICT_CODE => '28',
P_TRAN_NDATE => '2071-04-01',
P_TRAN_EDATE => '09-Jul-2017',
P_BANK_CODE => '11001016',
P_DEPOSIT_BANK_CODE => '11001016',
P_PO_CODE => '28-204-02',
P_ECONOMIC_CODE5 => '14221',
P_AMOUNT => 132,
P_PAN => NULL,
P_PAYEE_NAME => 'पुनरावेदन अदा',
P_PAYEE_ADD => 'Patan',
P_PHONE_NO => '553658',
P_TAX_YEAR => '2071/72',
P_PAYMENT_TYPE => 'A',
P_CHEQUE_DRAFT_NO => NULL,
P_DATETIME => SYSDATE,
P_CREATED_BY => 'GBL001',
P_TAX_FLAG => 'N',
P_CLEARANCE_EDATE => '17-jul-2017',
P_CLEARANCE_NDATE => '2071-04-01',
P_VOUCHER_NO => v_voucher_no,
P_CHEQUE_TYPE => NULL,
P_CHE_DRA_ISSUE_BANK => NULL,
P_VOUCHER_STATUS => 'T',
P_RECORD_LOCK_FLAG => 'Y',
P_VOUCHER_DATE => SYSDATE,
P_ADJUST_FLAG => 'N',
P_VOUCHER_NDATE => '2071-04-01',
P_DEPOSIT_SLIP_NO => '25764132',
P_COUNTER_CODE => 'P3',
P_UPDATE_DATETIME => SYSDATE,
P_UPDATE_BY => 'D00265',
P_PO_AMDANI_FLAG => 'Y',
P_DOLLAR_AMOUNT => 0,
P_UPDATE_NDATE => '2073-04-03',
P_DEPOSIT_SLIP_AUTO => 'N',
P_TRAN_BUD_YEAR => '2073/74',
p_error_code => v_error_code);
DBMS_OUTPUT.put_line (v_error_code);
DBMS_OUTPUT.put_line (v_voucher_no);
END;
但它会引发错误: -
SQL Error: 6553, SQLState: 65000
ERROR:: ORA-06553: PLS-306: wrong number or types of arguments
in call to 'PROC_INS_RMIS_BNK_VCHER_TABLE'
存储过程
create or replace PROCEDURE PROC_INS_RMIS_BNK_VCHER_TABLE (
P_BUD_YEAR VARCHAR2,
P_DISTRICT_CODE VARCHAR2, --NOT NULL
P_TRAN_NDATE VARCHAR2, --NOT NULL
P_TRAN_EDATE DATE,
P_BANK_CODE VARCHAR2, --NOT NULL
P_DEPOSIT_BANK_CODE VARCHAR2, --NOT NULL
P_PO_CODE VARCHAR2, --NOT NULL
P_ECONOMIC_CODE5 VARCHAR2, --NOT NULL
P_AMOUNT NUMBER,
P_PAN NUMBER,
P_PAYEE_NAME NVARCHAR2,
P_PAYEE_ADD NVARCHAR2,
P_PHONE_NO VARCHAR2,
P_TAX_YEAR VARCHAR2, --NOT NULL
P_PAYMENT_TYPE CHAR, --NOT NULL
P_CHEQUE_DRAFT_NO VARCHAR2,
P_DATETIME DATE,
P_CREATED_BY VARCHAR2, --NOT NULL
P_TAX_FLAG CHAR, --NOT NULL
P_CLEARANCE_EDATE DATE,
P_CLEARANCE_NDATE VARCHAR2,
P_VOUCHER_NO OUT VARCHAR2,
P_CHEQUE_TYPE CHAR,
P_CHE_DRA_ISSUE_BANK VARCHAR2,
P_VOUCHER_STATUS CHAR, --NOT NULL
P_RECORD_LOCK_FLAG CHAR, --NOT NULL
P_VOUCHER_DATE DATE,
P_ADJUST_FLAG CHAR, --NOT NULL
P_VOUCHER_NDATE CHAR, --NOT NULL
P_DEPOSIT_SLIP_NO NUMBER,
P_COUNTER_CODE VARCHAR2, --NOT NULL
P_UPDATE_DATETIME DATE,
P_UPDATE_BY VARCHAR2,
P_PO_AMDANI_FLAG CHAR,
P_DOLLAR_AMOUNT NUMBER,
P_UPDATE_NDATE VARCHAR2,
P_DEPOSIT_SLIP_AUTO CHAR,
P_TRAN_BUD_YEAR VARCHAR2,
p_error_code OUT VARCHAR2 --NOT NULL
--not null
)
IS
v_date DATE;
v_check_date DATE;
v_count NUMBER (1);
v_ret PLS_INTEGER;
v_same_day_check CHAR (1);
v_error_code VARCHAR2 (2500):=null;
v_SUB_DISTRICT_CODE VARCHAR2 (250);
v_MAIN_BANK_CODE VARCHAR2 (250);
v_bank_account_no_nep varchar2(250);
v_sno number;
BEGIN
SELECT SUBSTR (p_BANK_CODE, 1, 5) INTO v_MAIN_BANK_CODE FROM DUAL;
P_VOUCHER_NO := NULL;
v_date := TO_DATE (SYSDATE) - 1;
begin
SELECT count(voucher_no)
INTO v_count
FROM rmis7172.BANK_VOUCHER
WHERE main_bank_code = v_main_bank_code
AND deposit_slip_no = p_deposit_slip_no;
if v_count>=1 then
v_error_code:='Bank code and deposit slip no already exists';
end if;
end;
v_count:=0;
BEGIN
select bank_account_no_nep INTO v_bank_account_no_nep FROM RMIS_V_BANK
WHERE BANK_CODE=p_BANK_CODE;
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_bank_account_no_nep:=NULL;
WHEN TOO_MANY_ROWS THEN
v_bank_account_no_nep:=NULL;
END ;
FOR i IN 1 .. 30
LOOP
BEGIN
SELECT holiday_date
INTO v_check_date
FROM S_HOLIDAY_PARAMETER
WHERE v_date = TO_DATE (holiday_date);
v_date := v_date - 1;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
EXIT;
NULL;
END;
END LOOP;
---------------------------------------------------------
IF P_BANK_CODE IS NOT NULL AND V_BANK_ACCOUNT_NO_NEP IS NOT NULL
THEN
BEGIN
BEGIN
SELECT COUNT (*)
INTO v_count
FROM rmis7172.RMIS_DAY_CLOSE
WHERE bank_code = P_BANK_CODE
AND bank_account_no_nep = v_BANK_ACCOUNT_NO_NEP
AND tran_edate = TO_DATE (v_date);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_error_code := ':Data not found in day close table:';
END;
END;
-- CHECK DAY CLOSE OF SAME DATE
BEGIN
SELECT 'X'
INTO v_same_day_check
FROM rmis7172.RMIS_DAY_CLOSE
WHERE bank_code = p_bank_code
AND bank_account_no_nep = v_BANK_ACCOUNT_NO_NEP
AND from_edate = p_tran_edate;
v_error_code := ':Day Close has already done:';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
END;
ELSE
v_error_code :=
':P_BANK_CODE is null or/and P_BANK_ACCOUNT_NO_NEP is null:';
END IF;
IF p_bank_code IS NULL
THEN
v_error_code := v_error_code || ':Bank is null:';
NULL;
END IF;
IF v_bank_account_no_nep IS NULL
THEN
v_error_code := v_error_code || ':Account No is null:';
END IF;
IF P_deposit_slip_no IS NULL
THEN
v_error_code := v_error_code || ':Deposit slip No is null:';
END IF;
IF P_amount IS NULL
THEN
v_error_code := v_error_code || ':Amount is null:';
END IF;
IF P_economic_code5 IS NULL
THEN
v_error_code := v_error_code || ':Revenue Head is null:';
END IF;
IF P_po_code IS NULL
THEN
v_error_code := v_error_code || ':Paying Office is null:';
END IF;
IF P_PAYEE_NAME IS NULL
THEN
v_error_code := v_error_code || ':Payee Name is null:';
END IF;
IF P_payment_type <> 'A'
THEN
IF p_cheque_type IS NULL
THEN
v_error_code := ':Cheque Type is null:';
END IF;
IF P_CHE_DRA_ISSUE_BANK IS NULL
THEN
v_error_code := ':Cheque / Draft Issue Bank is null:';
END IF;
IF P_CHEQUE_DRAFT_NO IS NULL
THEN
v_error_code := ':Cheque / Draft No is null:';
END IF;
END IF;
IF v_error_code IS NULL
THEN
SELECT NVL (MAX (SNO), 0) + 1
INTO v_SNO
FROM BANK_VOUCHER
WHERE created_by = p_created_by;
BEGIN
SELECT sub_district_code
INTO v_SUB_DISTRICT_CODE
FROM RMIS_V_BANK
WHERE bank_code = p_bank_code
AND bank_account_no_nep = v_bank_account_no_nep;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
END;
INSERT INTO rmis7172.BANK_VOUCHER (BUD_YEAR,
DISTRICT_CODE,
SUB_DISTRICT_CODE,
TRAN_NDATE,
TRAN_EDATE,
BANK_CODE,
DEPOSIT_BANK_CODE,
PO_CODE,
ECONOMIC_CODE5,
AMOUNT,
PAN,
PAYEE_NAME,
PAYEE_ADD,
PHONE_NO,
TAX_YEAR,
PAYMENT_TYPE,
CHEQUE_DRAFT_NO,
DATETIME,
CREATED_BY,
TAX_FLAG,
CLEARANCE_EDATE,
CLEARANCE_NDATE,
VOUCHER_NO,
CHEQUE_TYPE,
CHE_DRA_ISSUE_BANK,
VOUCHER_STATUS,
RECORD_LOCK_FLAG,
VOUCHER_DATE,
ADJUST_FLAG,
VOUCHER_NDATE,
DEPOSIT_SLIp_NO,
SNO,
COUNTER_CODE,
MAIN_BANK_CODE,
UPDATE_DATETIME,
UPDATE_BY,
PO_AMDANI_FLAG,
DOLLAR_AMOUNT,
UPDATE_NDATE,
DEPOSIT_SLIp_AUTO,
TRAN_BUD_YEAR)
VALUES (P_BUD_YEAR,
P_DISTRICT_CODE,
v_SUB_DISTRICT_CODE,
P_TRAN_NDATE,
P_TRAN_EDATE,
P_BANK_CODE,
P_DEPOSIT_BANK_CODE,
P_PO_CODE,
P_ECONOMIC_CODE5,
P_AMOUNT,
P_PAN,
P_PAYEE_NAME,
P_PAYEE_ADD,
P_PHONE_NO,
P_TAX_YEAR,
P_PAYMENT_TYPE,
P_CHEQUE_DRAFT_NO,
P_DATETIME,
P_CREATED_BY,
P_TAX_FLAG,
P_CLEARANCE_EDATE,
P_CLEARANCE_NDATE,
P_VOUCHER_NO,
P_CHEQUE_TYPE,
P_CHE_DRA_ISSUE_BANK,
P_VOUCHER_STATUS,
P_RECORD_LOCK_FLAG,
P_VOUCHER_DATE,
P_ADJUST_FLAG,
P_VOUCHER_NDATE,
P_DEPOSIT_SLIP_NO,
v_SNO,
P_COUNTER_CODE,
v_MAIN_BANK_CODE,
P_UPDATE_DATETIME,
P_UPDATE_BY,
P_PO_AMDANI_FLAG,
P_DOLLAR_AMOUNT,
P_UPDATE_NDATE,
P_DEPOSIT_SLIP_AUTO,
P_TRAN_BUD_YEAR);
COMMIT;
SELECT voucher_no
INTO P_VOUCHER_NO
FROM rmis7172.BANK_VOUCHER
WHERE main_bank_code = v_main_bank_code
AND deposit_slip_no = p_deposit_slip_no;
ELSE
p_error_code := v_error_code;
END IF;
END;
我试图找出我的表接受的数据类型。除了日期(不确定上面的参数传递方法是否正确),我从dao类传递的值与我的表接受的数据类型相匹配。 我的问题是: -