2017-03-09 14 views
-4

を助け、これは私のSPは私のSP ..amです:これは結果が複数のrow.pleaseから成って取得私はそれがエラーを取得しています実行したときに私に

result consisted of multiple rows

CREATE DEFINER=`root`@`localhost` PROCEDURE `fourandfive`(IN choice varchar(10), IN upcstring varchar(100), IN Skustring varchar(100)) 
BEGIN 
set @numberofUpcs = length(upcstring); 
set @numberofSkus = length(Skustring); 
DROP TEMPORARY TABLE IF EXISTS upcs; 
create temporary table upcs (upcValue varchar(20)); 

while (@numberofUpcs>0) do 

set @oneupc = substring_index(upcstring,',',1); 

insert into upcs values(@oneupc); 

set @next = substr(upcstring,1,length(@oneupc)+1); 

set upcstring = replace(upcstring,@next,''); 

#select @next, @oneupc, upcstring; 



set @numberofUpcs = length(upcstring); 


end while; 



DROP TEMPORARY TABLE IF EXISTS skus; 
create temporary table skus (skuValue varchar(20)); 

while (@numberofSkus>0) do 

set @onesku = substring_index(Skustring,',',1); 

insert into skus values(@onesku); 

set @next = substr(Skustring,1,length(@onesku)+1); 

set Skustring = replace(Skustring,@next,''); 

#select @next, @oneupc, upcstring; 



set @numberofSkus = length(Skustring); 


end while; 




select count(*) from upcs into @upclen; 


#final loop 

while(@upclen>=1) do 

select upcValue into @Upc from upcs limit 1; 
select skuValue into @Sku from skus limit 1; 


IF(choice='four') THEN 

select shipping into @shipping from store_data where upc = @Upc and sku = @Sku limit 1; 
select ([email protected]) into @reprice from prices where upc = @Upc and sku = @Sku limit 1; 
update revised_price set price = @reprice where upc = @Upc; 
delete from skus where skuValue = @Sku; 
set @Sku = 0; 

#select @shipping,@reprice; 


ELSE IF(choice = 'five') then 
select min(price) into @minimumprice from prices where upc= @Upc group by upc; 
update revised_price set price = @minimumprice where upc = @Upc; 
end if; 
end if; 
set @upclen = @upclen-1; 
delete from upcs where upcValue = @Upc; 
set @Upc = 0; 
end while; 
drop table upcs; 
drop table skus; 

END 
+2

Plsでは、エラーが発生した場所を特定することはできませんが、場所を教えてください。 – Shadow

答えて

0
DROP PROCEDURE fourandfive; 
DELIMITER $$ 

CREATE PROCEDURE fourandfive(IN choice varchar(10),IN upcstring VARCHAR(255),IN Skustring varchar(100)) 
BEGIN 
set @numberofUpcs = length(upcstring); 
set @numberofSkus = length(Skustring); 
DROP TEMPORARY TABLE IF EXISTS upcs; 
create temporary table upcs (upcValue varchar(20)); 

while (@numberofUpcs>0) do 

set @oneupc = substring_index(upcstring,',',1); 

insert into upcs values(@oneupc); 

set @next = substr(upcstring,1,length(@oneupc)+1); 

set upcstring = replace(upcstring,@next,''); 

#select @next, @oneupc, upcstring; 



set @numberofUpcs = length(upcstring); 


end while; 



DROP TEMPORARY TABLE IF EXISTS skus; 
create temporary table skus (skuValue varchar(20)); 

while (@numberofSkus>0) do 

set @onesku = substring_index(Skustring,',',1); 

insert into skus values(@onesku); 

set @next = substr(Skustring,1,length(@onesku)+1); 

set Skustring = replace(Skustring,@next,''); 

#select @next, @oneupc, upcstring; 



set @numberofSkus = length(Skustring); 


end while; 




select count(*) from upcs into @upclen; 


#final loop 

while(@upclen>=1) do 

select upcValue into @Upc from upcs limit 1; 
select skuValue into @Sku from skus limit 1; 


IF(choice='four') THEN 

select shipping into @shipping from store_data where upc = @Upc and sku = @Sku limit 1; 
select ([email protected]) into @reprice from prices where upc = @Upc and sku = @Sku limit 1; 
update revised_price set price = @reprice where upc = @Upc; 
delete from skus where skuValue = @Sku; 
set @Sku = 0; 

#select @shipping,@reprice; 


ELSE IF(choice = 'five') then 
select min(price) into @minimumprice from prices where upc= @Upc; 
update revised_price set price = @minimumprice where upc = @Upc; 
end if; 
end if; 
set @upclen = @upclen-1; 
delete from upcs where upcValue = @Upc; 
set @Upc = 0; 
end while; 
drop table upcs; 
drop table skus; 

END 

ただ、上記してみてくださいコード。

あなたはそれはあなたがこの意志が役立ちます

select min(price) into @minimumprice from prices where upc= @Upc ; 

希望を試してみて、代わりにその複数の行を生成します

select min(price) into @minimumprice from prices where upc= @Upc group by upc; 

をしていました。

関連する問題