Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure - Error on cursor

Status
Not open for further replies.

snufse1

Programmer
Joined
Nov 14, 2008
Messages
66
Location
US
I get error:

SQL0504 35 23 Position 10 Cursor C1 not declared.


-- *****************************************************************************
-- ** Program: get_jobqty **
-- ** Description: Get Job Quantities by Cost Code - File F0902LC **
-- *****************************************************************************
create procedure get_jobqty
(in @jobnumber char(12))
result set 1
language sql
reads sql data
begin
declare c1 scroll cursor with return for
select gbsub, DECIMAL(SUM(gban01 + gban02 + gban03 +
gban04 + gban05 + gban06 + gban07 + gban08 +
gban09 + gban10 + gban11 + gban12 + gban13 +
gban14)/FLOAT(100.00),38,2) as sum_qty, gmdl01 as itemname
from vgiprddta/f0902lc left outer join vgiprddta.f0901jb
on vgiprddta.f0902lc.gbmcu = vgiprddta.f0901jb.gmmcu
where
vgiprddta.f0902lc.gblt = 'AU' and
vgiprddta.f0902lc.gbobj = ' ' and
vgiprddta.f0901jb.gmpec = 'N'
GROUP BY gbsub;
open c1;
set result sets cursor c1;
end;
 
gmdl01 is missing in the GROUP BY clause so the cursor is not declared.
 
That worked, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top