|
-
May 9th, 2008, 03:47 AM
#1
Thread Starter
Member
MYSQL Cursor doesnt working when inside select is null
I have this stored procedure
CREATE PROCEDURE `spCar`()
begin
declare exit1 int default 0;
declare rec1 char(50);
declare rec2 char(50);
declare vgas int;
declare cur1 cursor for select distinct car,driver from dates;
declare exit handler for not found set exit1=1;
open cur1;
repeat
fetch cur1 into rec2,rec1;
-- select gas into vgas from someTable where car=rec2 and driver=rec1;
select rec2,rec1,c_rest;
until exit1=1 end repeat;
close cur1;
end
if I uncommnet the line above ... the sp will not show anything if at some point the vgas variable is null
if I leave it commented will display the right number of records but I need my sp with vgas variable ... and this variable might be null at some point
-
May 9th, 2008, 04:15 AM
#2
Addicted Member
Re: MYSQL Cursor doesnt working when inside select is null
I don't know much about stored procedures. May be you could try
Code:
SELECT IFNULL(gas, 0) INTO vgas FROM someTable WHERE car=rec2 AND driver=rec1;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|