Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

syntax error! an easy one for somebody!

3 posts in General Discussion Last posting was on 2004-10-28 16:07:31.0Z
Kenneth Panacy Posted on 2004-10-27 20:59:19.0Z
From: "Kenneth Panacy" <kpanacy@tpigroup.com>
Newsgroups: ianywhere.public.general
Subject: syntax error! an easy one for somebody!
Lines: 24
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: gw_boston.phx.com
X-Original-NNTP-Posting-Host: gw_boston.phx.com
Message-ID: <41800c27$1@forums-1-dub>
Date: 27 Oct 2004 13:59:19 -0700
X-Trace: forums-1-dub 1098910759 12.11.184.129 (27 Oct 2004 13:59:19 -0700)
X-Original-Trace: 27 Oct 2004 13:59:19 -0700, gw_boston.phx.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3792
Article PK: 7695

Hello,

I'm trying to do a simple If Exists... table update on a
"Sybase Adaptive Server Anywhere e-Business Anywhere" db on
a Linux server. I'm getting a syntax error but I don't know
enough about Sybase to see what's wrong here.

Here's my code.
IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070388')
THEN BEGIN INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
VALUES ('070388', '070388', NOW()); INSERT INTO LP_DIV_GRP
(GRP_CD, DIV_NUM) VALUES ('ALL','070388');END
IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070416')
THEN BEGIN INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
VALUES ('070416', '070416', NOW()); INSERT INTO LP_DIV_GRP
(GRP_CD, DIV_NUM) VALUES ('ALL','070416');END

Is it okay that the lines have several commands and are
separated by semi-colons?

Thanks.
Ken


"Bruce Hay" <h_a_y Posted on 2004-10-28 13:35:43.0Z
From: "Bruce Hay" <h_a_y@i~a~n~y~w~h~e~r~e.c_o_m>
Newsgroups: ianywhere.public.general
References: <41800c27$1@forums-1-dub>
Subject: Re: syntax error! an easy one for somebody!
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: hay-t30.sybase.com
X-Original-NNTP-Posting-Host: hay-t30.sybase.com
Message-ID: <4180f5af$1@forums-1-dub>
Date: 28 Oct 2004 06:35:43 -0700
X-Trace: forums-1-dub 1098970543 10.25.99.98 (28 Oct 2004 06:35:43 -0700)
X-Original-Trace: 28 Oct 2004 06:35:43 -0700, hay-t30.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3794
Article PK: 7696

IF statements should be in the form:
IF (condition ) THEN
// statements to execute
END IF;
Your code should be:

IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070388') THEN
INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
VALUES ('070388', '070388', NOW());
INSERT INTO LP_DIV_GRP (GRP_CD, DIV_NUM)
VALUES ('ALL','070388');
END IF;
IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070416') THEN
INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
VALUES ('070416', '070416', NOW());
INSERT INTO LP_DIV_GRP (GRP_CD, DIV_NUM)
VALUES ('ALL','070416');
END IF;

If DIV_NUM is a number, it should be defined as such; the values you insert
should be numbers rather than strings.

Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
Developer Community at http://www.ianywhere.com/developer

"Kenneth Panacy" <kpanacy@tpigroup.com> wrote in message
news:41800c27$1@forums-1-dub...
> Hello,
>
> I'm trying to do a simple If Exists... table update on a
> "Sybase Adaptive Server Anywhere e-Business Anywhere" db on
> a Linux server. I'm getting a syntax error but I don't know
> enough about Sybase to see what's wrong here.
>
> Here's my code.
> IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070388')
> THEN BEGIN INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
> VALUES ('070388', '070388', NOW()); INSERT INTO LP_DIV_GRP
> (GRP_CD, DIV_NUM) VALUES ('ALL','070388');END
> IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070416')
> THEN BEGIN INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
> VALUES ('070416', '070416', NOW()); INSERT INTO LP_DIV_GRP
> (GRP_CD, DIV_NUM) VALUES ('ALL','070416');END
>
> Is it okay that the lines have several commands and are
> separated by semi-colons?
>
> Thanks.
> Ken
>
>


Kenneth Panacy Posted on 2004-10-28 16:07:31.0Z
From: "Kenneth Panacy" <kpanacy@tpigroup.com>
Newsgroups: ianywhere.public.general
References: <41800c27$1@forums-1-dub> <4180f5af$1@forums-1-dub>
Subject: Re: syntax error! an easy one for somebody!
Lines: 62
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: gw_boston.phx.com
X-Original-NNTP-Posting-Host: gw_boston.phx.com
Message-ID: <41811943$1@forums-1-dub>
Date: 28 Oct 2004 09:07:31 -0700
X-Trace: forums-1-dub 1098979651 12.11.184.129 (28 Oct 2004 09:07:31 -0700)
X-Original-Trace: 28 Oct 2004 09:07:31 -0700, gw_boston.phx.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3795
Article PK: 7694

Thanks very much! That was exactly what I needed.

Ken

"Bruce Hay" <h_a_y@i~a~n~y~w~h~e~r~e.c_o_m> wrote in message
news:4180f5af$1@forums-1-dub...
> IF statements should be in the form:
> IF (condition ) THEN
> // statements to execute
> END IF;
> Your code should be:
>
> IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070388') THEN
> INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
> VALUES ('070388', '070388', NOW());
> INSERT INTO LP_DIV_GRP (GRP_CD, DIV_NUM)
> VALUES ('ALL','070388');
> END IF;
> IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070416') THEN
> INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
> VALUES ('070416', '070416', NOW());
> INSERT INTO LP_DIV_GRP (GRP_CD, DIV_NUM)
> VALUES ('ALL','070416');
> END IF;
>
> If DIV_NUM is a number, it should be defined as such; the values you
insert
> should be numbers rather than strings.
>
> Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
> Developer Community at http://www.ianywhere.com/developer
>
> "Kenneth Panacy" <kpanacy@tpigroup.com> wrote in message
> news:41800c27$1@forums-1-dub...
> > Hello,
> >
> > I'm trying to do a simple If Exists... table update on a
> > "Sybase Adaptive Server Anywhere e-Business Anywhere" db on
> > a Linux server. I'm getting a syntax error but I don't know
> > enough about Sybase to see what's wrong here.
> >
> > Here's my code.
> > IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070388')
> > THEN BEGIN INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
> > VALUES ('070388', '070388', NOW()); INSERT INTO LP_DIV_GRP
> > (GRP_CD, DIV_NUM) VALUES ('ALL','070388');END
> > IF NOT EXISTS(SELECT * FROM LP_DIV WHERE DIV_NUM='070416')
> > THEN BEGIN INSERT INTO LP_DIV (DIV_NUM, NAME, CREATE_DTM)
> > VALUES ('070416', '070416', NOW()); INSERT INTO LP_DIV_GRP
> > (GRP_CD, DIV_NUM) VALUES ('ALL','070416');END
> >
> > Is it okay that the lines have several commands and are
> > separated by semi-colons?
> >
> > Thanks.
> > Ken
> >
> >
>
>