我在存储过程中遇到以下问题:
BEGIN
declare docId int(11);
declare sendingUserVar varchar(100);
declare accountManagerVar varchar(100);
declare ppp varchar(100);
declare zzz varchar(100);
declare varTotalNat double(10,2);
declare varStageName varchar(50);
declare varAccountId varchar(50);
declare varCompanyName varchar(500);
declare varClientName varchar(500);
declare varPhone varchar(500);
declare varEmail varchar(500);
declare varBillingCity varchar(500);
declare varBillingCountry varchar(500);
declare varBillingState varchar(500);
declare docCursor cursor for select documentId FROM Export.Document;
open docCursor;
start_loop: loop
fetch docCursor into docId;
select docId;
SELECT SUM(total) INTO varTotalNAT FROM DocumentItem WHERE documentId = docId;
SELECT AccountId, StageName, CreatedById, OwnerId
INTO varAccountId, varStageName, sendingUserVar, accountManagerVar
FROM sfExport.Opportunity WHERE Opportunity_Number__c = docId LIMIT 1;
SELECT Name, Phone, Site_Visit_Notes__c, BillingCity, BillingCountry, BillingState
INTO varCompanyName, varPhone, varEmail, varBillingCity, varBillingCountry, varBillingState
FROM sfExport.Account WHERE Id = varAccountId LIMIT 1;
SELECT Name INTO varClientName FROM sfExport.Contact WHERE AccountId = varAccountId LIMIT 1;
UPDATE Export.Document
SET
totalNAT = varTotalNAT,
stage = varStageName,
sendingUser = sendingUserVar,
accountManager = accountManagerVar,
companyName = varCompanyName,
name = varClientName,
phone = varPhone,
email = varEmail,
city = varBillingCity,
physicalCountry = varBillingCountry,
physicalState = varBillingState
WHERE documentId = docId;
select('a row processed',docId);
end loop;
close docCursor;
END
每当我调用此存储过程时,我都会得到ERROR 1241 (21000): Operand should contain 1 column(s)
。问题是“为什么?”,因为我LIMIT 1
设置了所有“子查询”
答案 0 :(得分:1)
使用 CONCAT *
select CONCAT('a row processed',docId);
或给2栏后退
select 'a row processed',docId;