我已经创建了用于创建测试数据的存储过程:
create procedure INSERT_INTO_VALIDATEEXISTINGYESID(IN customerid varchar(50), IN dgaccounttype varchar(50),
IN scenario varchar(1000), IN yesid varchar(50),
IN accountnumber varchar(50), IN accounttype varchar(30),
IN billingaccountnumber varchar(50), IN valid varchar(10),
IN responsecode varchar(20))
BEGIN
DECLARE `l_customerid` VARCHAR(50);
DECLARE `l_dgaccounttype` VARCHAR(50);
DECLARE `l_scenario` VARCHAR(1000);
DECLARE `l_yesid` VARCHAR(50);
DECLARE `l_accountnumber` VARCHAR(50);
DECLARE `l_accounttype` VARCHAR(30);
DECLARE `l_billingaccountnumber` VARCHAR(50);
DECLARE `l_valid` VARCHAR(50);
DECLARE `l_responsecode` VARCHAR(50);
SET l_customerid = customerid;
SET l_dgaccounttype = dgaccounttype;
IF (scenario IS NOT NULL) THEN
SET l_scenario = scenario;
ELSE
SET l_scenario = NULL;
END IF;
IF (yesid IS NOT NULL) THEN
IF (yesid = '<service_auto>') THEN
SET l_yesid = (SELECT serviceaccountyesid
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype);
ELSEIF (yesid = '<customer_auto>') THEN
SET l_yesid = (SELECT `customeraccountyesid`
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype);
ELSE
SET l_yesid = yesid;
END IF;
ELSE
SET l_yesid = '';
END IF;
IF (accountnumber IS NOT NULL) THEN
IF (accountnumber = '<service_auto>') THEN
SET l_accountnumber = (SELECT `serviceaccountnumber`
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype);
ELSEIF (accountnumber = '<customer_auto>') THEN
SET l_accountnumber = (SELECT `customeraccountnumber`
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype);
INSERT INTO debug(valueobj) VALUES (l_accountnumber);
ELSEIF (accountnumber = '<billing_auto>') THEN
SET l_accountnumber = (SELECT `billingaccountnumber`
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype);
ELSE
SET l_accountnumber = accountnumber;
END IF;
ELSE
SET l_accountnumber = '';
END IF;
insert into debug(valueobj) values (l_accountnumber);
IF (accounttype = '<auto>') THEN
SET l_accounttype =
(SELECT `accounttype`
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype
LIMIT 1);
ELSE
SET l_accounttype = accounttype;
END IF;
insert into debug(valueobj) values (accounttype);
IF (billingaccountnumber = '<auto>') THEN
SET l_billingaccountnumber = (SELECT billingaccountnumber
FROM createcustomer
WHERE customerid = l_customerid
AND dgaccounttype = l_dgaccounttype);
ELSE
SET l_billingaccountnumber = billingaccountnumber;
END IF;
SET l_responsecode = responsecode;
SET l_valid = valid;
INSERT INTO `validateexistingyesid`(customerid, dgaccounttype, scenario, yesid, `accountnumber`, `accounttype`,
`billingaccountnumber`, valid, responsecode, createddate)
VALUES (l_customerid, l_dgaccounttype, l_scenario, l_yesid, l_accountnumber, l_accounttype,
l_billingaccountnumber, l_valid, l_responsecode, NOW());
END;
但是当我执行上述过程时,出现以下错误:
[21000][1242] Subquery returns more than 1 row
我已经检查了过程中的每个选择,并且它仅返回一个值。但是在存储过程中,它返回多个值。 EQUALS
的行为类似于LIKE
。
请帮助。