Hi,
In stored procedures within the compound statement the following sequence is
required:
1. Declare Section
1.1. Define SQL Variables
1.2. Define SQL Conditions
1.3. Define Return Values
1.4. Define Cursors
1.5. Define Codition/Exception/Continue Handlers
2. all other Statements
In your example you defined the cursor after a Call Statement, which was the
wrong sequence.
Just move the CALL after the Declare-Statement.
FYI the declare curorsor statement can be compared with user opended files
defined in the F-Specs.
As long as no open occurs, nothing happens
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces+hauser=sss-software.de@xxxxxxxxxxxx
[
mailto:midrange-l-bounces+hauser=sss-software.de@xxxxxxxxxxxx] Im Auftrag
von Alan Campin
Gesendet: Friday, April 20, 2007 01:46
An: midrange-l@xxxxxxxxxxxx
Betreff: Compile problems with SQL Stored Procedures
I like SQL Stored Procedures but they have the quirkiest behaviors.
I have this stored procedure. I see plenty of examples of the same thing but
when I compile I get a:
SQL0104 30 20 Position 13 Token C1 was not valid. Valid tokens:
GLOBAL.
If I comment out the call statement, it will compile but not with it in
there.
I have run into this before where SQL will not compile something before the
declare statement even though the books have all kinds of examples.
Anybody got an idea what the devil is going on here?
Create Procedure MAPDBA/MRPGETSTATUS2
(In InItemNumber Varchar(15),
In InProgramEnv Char(1),
In InFileEnv Char(1))
Dynamic Result Sets 1
Language SQL
Not Deterministic
Reads SQL Data
Set Option DbgView = *Source, DatFmt = *ISO, DatSep = '-'
Begin
Call SetLibraryList(InProgramEnv,InFileEnv);
Declare C1 Asensitive Scroll Cursor With Return For
Select VarChar(a.FITEM,15,037) As ItemNumber,
iDate(a.SSTDT) As StartDate,
iDate(a.ODUDT) As DueDate,
VarChar(a.ORDNO,7,037) As OrderNumber,
VarChar(c.OPSEQ,4,037) As OperationsSequence,
VarChar(c.OPDSC,20,037) As OperationsDescription,
VarChar(b.ITDSC,30,037) As ItemDescription,
VarChar(c.WKCTR,5,037) As WorkCenter,
VarChar(c.OPSTC,2,037) As OperationStatus,
a.DOSCH As DaysOffSchedule,
VarChar(a.JOBNO,12,037) As Notes
From MOMAST a
Inner Join ITMRVA b
On b.STID = a.FITWH And
b.ITNBR = a.FITEM
Inner Join MOROUT c
On c.ORDNO = a.ORDNO And
c.WKCTR <> '0000'
Where a.FITEM = InItemNumber And
a.OSTAT <= '40'
Order By a.FITWH,
iDate(a.ODUDT),
iDate(a.SSTDT),
a.ORDNO,
c.OPSEQ;
Open C1;
End;
As an Amazon Associate we earn from qualifying purchases.