× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



So are you saying that SETting a variable after DECLARING a cursor is
still ok? The values of the variables will not be used until the Cursor
is opened?

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Tuesday, July 07, 2009 9:58 AM
To: Midrange Systems Technical Discussion
Subject: RE: Stored Procedure with different SUMs

I got an error very similar to yours. Some of my sample code was:

Create Procedure
rob.deletethisprocedure ( In customerNumber dec (6,0))
Language SQL

Begin

Declare MyVar int;
Declare MyResult int;
Declare WorkLines int;

Set MyVar = 3;

Declare C1 cursor for
select hlins
from gdidivf.ech
where hcust=customerNumber;

...

SQL State: 42601
Vendor Code: -104
Message: [SQL0104] Token C1 was not valid. Valid tokens: GLOBAL. Cause .
.
. . . : A syntax error was detected at token C1. Token C1 is not a
valid token. A partial list of valid tokens is GLOBAL. This list
assumes
that the statement is correct up to the token. The error may be earlier

in the statement, but the syntax of the statement appears to be valid up

to this point. Recovery . . . : Do one or more of the following and
try
the request again: -- Verify the SQL statement in the area of the token
C1. Correct the statement. The error could be a missing comma or
quotation mark, it could be a misspelled word, or it could be related to

the order of clauses. -- If the error token is <END-OF-STATEMENT>,
correct
the SQL statement because it does not end with a valid clause.

All I did to fix it was change the order to

Create Procedure
rob.deletethisprocedure ( In customerNumber dec (6,0))
Language SQL

Begin

Declare MyVar int;
Declare MyResult int;
Declare WorkLines int;

Declare C1 cursor for
select hlins
from gdidivf.ech
where hcust=customerNumber;

Set MyVar = 3;
...

The error was that I had a Declare after an executable. Next time humor

the list and post the entire code. Now you see why?


Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.