Help!!! syntax error
Posted in 2009
Topics: Stored Procedures & SPL
Hi everybody, Im trying to create a simple store procedure but I get
an error when I define the variables.
Code:
CREATE PROCEDURE scope()
DEFINE x,y,z INT; LET x = 5;
LET y = 10;
LET z = x + y; --z is 15
BEGIN
DEFINE x, q INT;
DEFINE z CHAR(5);
LET x = 100;
LET q = x + y; -- q = 110
LET z = 'silly'; -- z receives a character value
END
LET y = x; -- y is now 5
LET x = z; -- z is now 15, not 'silly'
END PROCEDURE;
Error:
Error: A syntax error has occurred.
SQLState: 42000
ErrorCode: -201
Position: 41
Error occured in:
CREATE PROCEDURE scope()
DEFINE x,y,z INT
You need a semi-colon after the closing parenthesis of the procedure's
argument list. So:
CREATE PROCEDURE scope(); DEFINE x,y,z INT;
LET x = 5;
LET y = 10;
LET z = x + y; --z is 15
BEGIN
DEFINE x, q INT;
DEFINE z CHAR(5);
LET x = 100;
LET q = x + y; -- q = 110
LET z = 'silly'; -- z receives a character value
END
LET y = x; -- y is now 5
LET x = z; -- z is now 15, not 'silly'
END PROCEDURE;
Art
Art S. Kagel
Oninit (www.oninit.com)
IIUG Board of Directors (art@iiug.org)
Disclaimer: Please keep in mind that my own opinions are my own opinions and
do not reflect on my employer, Oninit, the IIUG, nor any other organization
with which I am associated either explicitly or implicitly. Neither do
those opinions reflect those of other individuals affiliated with any entity
with which I am affiliated nor those of the entities themselves.
On Thu, Dec 3, 2009 at 12:16 PM, Oskr <oscar.rsz@gmail.com> wrote:
> Hi everybody, Im trying to create a simple store procedure but I get
> an error when I define the variables.
>
> Code:
>
> CREATE PROCEDURE scope()
> DEFINE x,y,z INT;> LET x = 5;
> LET y = 10;
> LET z = x + y; --z is 15
> BEGIN
> DEFINE x, q INT;
> DEFINE z CHAR(5);
> LET x = 100;
> LET q = x + y; -- q = 110
> LET z = 'silly'; -- z receives a character value
> END
> LET y = x; -- y is now 5
> LET x = z; -- z is now 15, not 'silly'
> END PROCEDURE;
>
>
>
> Error:
>
> Error: A syntax error has occurred.
> SQLState: 42000
> ErrorCode: -201
> Position: 41
> Error occured in:
> CREATE PROCEDURE scope()
> DEFINE x,y,z INT> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
On 3 dic, 11:24, Art Kagel <art.ka...@gmail.com> wrote:
> You need a semi-colon after the closing parenthesis of the procedure's
> argument list. So:
>
> CREATE PROCEDURE scope();> DEFINE x,y,z INT;
> LET x = 5;
> LET y = 10;
> LET z = x + y; --z is 15
> BEGIN
> DEFINE x, q INT;
> DEFINE z CHAR(5);
> LET x = 100;
> LET q = x + y; -- q = 110
> LET z = 'silly'; -- z receives a character value
> END
> LET y = x; -- y is now 5
> LET x = z; -- z is now 15, not 'silly'
> END PROCEDURE;
>
> Art
>
> Art S. Kagel
> Oninit (www.oninit.com)
> IIUG Board of Directors (a...@iiug.org)
>
> Disclaimer: Please keep in mind that my own opinions are my own opinions and
> do not reflect on my employer, Oninit, the IIUG, nor any other organization
> with which I am associated either explicitly or implicitly. Neither do
> those opinions reflect those of other individuals affiliated with any entity
> with which I am affiliated nor those of the entities themselves.
>
>
>
> On Thu, Dec 3, 2009 at 12:16 PM, Oskr <oscar....@gmail.com> wrote:
> > Hi everybody, Im trying to create a simple store procedure but I get
> > an error when I define the variables.
>
> > Code:
>
> > CREATE PROCEDURE scope()> > DEFINE x,y,z INT;
> > LET x = 5;
> > LET y = 10;
> > LET z = x + y; --z is 15
> > BEGIN
> > DEFINE x, q INT;
> > DEFINE z CHAR(5);
> > LET x = 100;
> > LET q = x + y; -- q = 110
> > LET z = 'silly'; -- z receives a character value
> > END
> > LET y = x; -- y is now 5
> > LET x = z; -- z is now 15, not 'silly'
> > END PROCEDURE;
>
> > Error:
>
> > Error: A syntax error has occurred.
> > SQLState: 42000
> > ErrorCode: -201
> > Position: 41
> > Error occured in:
> > CREATE PROCEDURE scope()> > DEFINE x,y,z INT
> > _______________________________________________
> > Informix-list mailing list
> > Informix-l...@iiug.org
> >http://www.iiug.org/mailman/listinfo/informix-list- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
Now I get the next error:
Error: A syntax error has occurred.
SQLState: 42000
ErrorCode: -201
Position: 23
Error occured in:
CREATE PROCEDURE scope()
Hmmm...
Your SQL is syntactically correct. It's possible to create it using
dbaccess.
But your error seems to be an ODBC error. You have "--" comments. Can you
remove them and try? How are you passing the SQL text? Are you able to send
line breaks?
Please remove the comments and try again....
Regards.
On Thu, Dec 3, 2009 at 5:55 PM, Oskr <oscar.rsz@gmail.com> wrote:
> On 3 dic, 11:24, Art Kagel <art.ka...@gmail.com> wrote:
> > You need a semi-colon after the closing parenthesis of the procedure's
> > argument list. So:
> >
> > CREATE PROCEDURE scope();> > DEFINE x,y,z INT;
> > LET x = 5;
> > LET y = 10;
> > LET z = x + y; --z is 15
> > BEGIN
> > DEFINE x, q INT;
> > DEFINE z CHAR(5);
> > LET x = 100;
> > LET q = x + y; -- q = 110
> > LET z = 'silly'; -- z receives a character value
> > END
> > LET y = x; -- y is now 5
> > LET x = z; -- z is now 15, not 'silly'
> > END PROCEDURE;
> >
> > Art
> >
> > Art S. Kagel
> > Oninit (www.oninit.com)
> > IIUG Board of Directors (a...@iiug.org)
> >
> > Disclaimer: Please keep in mind that my own opinions are my own opinions
> and
> > do not reflect on my employer, Oninit, the IIUG, nor any other
> organization
> > with which I am associated either explicitly or implicitly. Neither do
> > those opinions reflect those of other individuals affiliated with any
> entity
> > with which I am affiliated nor those of the entities themselves.
> >
> >
> >
> > On Thu, Dec 3, 2009 at 12:16 PM, Oskr <oscar....@gmail.com> wrote:
> > > Hi everybody, Im trying to create a simple store procedure but I get
> > > an error when I define the variables.
> >
> > > Code:
> >
> > > CREATE PROCEDURE scope()
> > > DEFINE x,y,z INT;> > > LET x = 5;
> > > LET y = 10;
> > > LET z = x + y; --z is 15
> > > BEGIN
> > > DEFINE x, q INT;
> > > DEFINE z CHAR(5);
> > > LET x = 100;
> > > LET q = x + y; -- q = 110
> > > LET z = 'silly'; -- z receives a character value
> > > END
> > > LET y = x; -- y is now 5
> > > LET x = z; -- z is now 15, not 'silly'
> > > END PROCEDURE;
> >
> > > Error:
> >
> > > Error: A syntax error has occurred.
> > > SQLState: 42000
> > > ErrorCode: -201
> > > Position: 41
> > > Error occured in:
> > > CREATE PROCEDURE scope()
> > > DEFINE x,y,z INT> > > _______________________________________________
> > > Informix-list mailing list
> > > Informix-l...@iiug.org
> > >http://www.iiug.org/mailman/listinfo/informix-list- Ocultar texto de la
> cita -
> >
> > - Mostrar texto de la cita -
>
> Now I get the next error:
>
> Error: A syntax error has occurred.
> SQLState: 42000
> ErrorCode: -201
> Position: 23
> Error occured in:
> CREATE PROCEDURE scope()> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...
On Dec 3, 9:16 am, Oskr <oscar....@gmail.com> wrote:
> Hi everybody, Im trying to create a simple store procedure but I get
> an error when I define the variables.
>
> Code:
>
> CREATE PROCEDURE scope()> DEFINE x,y,z INT;
> LET x = 5;
> LET y = 10;
> LET z = x + y; --z is 15
> BEGIN
> DEFINE x, q INT;
> DEFINE z CHAR(5);
> LET x = 100;
> LET q = x + y; -- q = 110
> LET z = 'silly'; -- z receives a character value
> END
> LET y = x; -- y is now 5
> LET x = z; -- z is now 15, not 'silly'
> END PROCEDURE;
>
> Error:
>
> Error: A syntax error has occurred.
> SQLState: 42000
> ErrorCode: -201
> Position: 41
> Error occured in:
> CREATE PROCEDURE scope()> DEFINE x,y,z INT
Are you using ISQL to create the stored procedure?
If so, don't; it won't work.
-=JL=-