如何在java类中调用这个存储过程?并声明一个等于它的字符串变量?
GenORFinalSP(SP 名称)
BEGIN
DECLARE temp_OR VARCHAR(50);
CALL GenORSP(xRCO, xReceipt, @tempCount, @tempORNo);
SET xROR = @tempORNo;
WHILE xROR = (SELECT TPAY_RECEIPT_NO FROM tbl_tax_payment WHERE TPAY_RECEIPT_NO = xROR)
DO
CALL GenORSP(xRCO, xReceipt, @tempCount, @tempORNo);
END WHILE;
SET xROR = @tempORNo;
SET xCount = @tempCount;
END
例如我想声明一个字符串变量 test 等于它。
String test = GenORFinalSP();
更新:
这是代码GenORSP
BEGIN
DECLARE var_MAX BIGINT(20);
DECLARE temp_COUNT BIGINT(20);
DECLARE var_YEAR VARCHAR(4);
DECLARE var_tempYEAR VARCHAR(4);
DECLARE var_END INT(1);
SET temp_COUNT = 0;
SET var_END = 0;
SET var_YEAR = YEAR(CURRENT_TIMESTAMP);
SELECT ( CASE WHEN MAX(TPAY_COUNTER) IS NULL THEN 0 ELSE MAX(TPAY_COUNTER) END ), YEAR (DATE(TPAY_ISSUED_DATE)) INTO var_MAX, var_tempYEAR FROM tbl_tax_payment where TPAY_ISSUED_DATE = (SELECT MAX(TPAY_ISSUED_DATE) FROM tbl_tax_payment WHERE RCO_CODE = xRCO AND RECEIPT_TYPE = xReceipt AND YEAR(DATE(TPAY_ISSUED_DATE)) = YEAR(current_date) AND TPAY_COUNTER = (
SELECT
MAX(TPAY_COUNTER)
FROM
tbl_tax_payment
WHERE
RCO_CODE = xRCO
AND RECEIPT_TYPE = xReceipt
AND YEAR (DATE(TPAY_ISSUED_DATE)) = YEAR (CURRENT_DATE)
)) AND TPAY_COUNTER = (
SELECT
MAX(TPAY_COUNTER)
FROM
tbl_tax_payment
WHERE
RCO_CODE = xRCO
AND RECEIPT_TYPE = xReceipt
AND YEAR (DATE(TPAY_ISSUED_DATE)) = YEAR (CURRENT_DATE)
);
IF var_YEAR <> var_tempYEAR THEN
SET var_END = (SELECT IF(YEAR(current_date) = var_tempYEAR,0,1));
IF var_END = 1 THEN
SET var_MAX = 0;
END IF;
END IF;
IF var_MAX = 0 THEN
SET temp_COUNT = 1;
SET var_OR = CONCAT(xReceipt, var_YEAR, '-', xRCO, '-', LPAD(temp_COUNT, 6, '0'));
ELSE
SET temp_COUNT = var_MAX + 1;
SET var_OR = CONCAT(xReceipt, var_YEAR, '-', xRCO, '-', LPAD(temp_COUNT, 6, '0'));
END IF;
SET var_COUNT = temp_COUNT;
END