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.

What is rong with this function

8 posts in General Discussion Last posting was on 2004-02-23 16:25:29.0Z
Chandresh Patel Posted on 2004-02-23 15:07:36.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
Subject: What is rong with this function
Lines: 32
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: ac9b18bd.ipt.aol.com
Message-ID: <403a1742@forums-2-dub>
X-Original-Trace: 23 Feb 2004 07:07:46 -0800, ac9b18bd.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 23 Feb 2004 07:07:12 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 23 Feb 2004 07:07:36 -0800
X-Trace: forums-1-dub 1077548856 10.22.108.75 (23 Feb 2004 07:07:36 -0800)
X-Original-Trace: 23 Feb 2004 07:07:36 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2592
Article PK: 5729

Hi,

I am using Sybase Anywhere 9.0.0(1108)

I create one function in Sybase Central and it gives me error like

[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access
violation: near 'BEGIN' in ...[BEGIN] ...
SQLCODE: -131
SQLSTATE: 42000

Here is the syntax of function:

ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
DATE)
BEGIN
int mDOW = 0;
mDOW = SELECT DOW(eDate);

if mDOW = 7 THEN
sDate = SELECT dateadd(day, -6, eDate)
ELSE
eDate = SELECT dateadd(day, 7-mDOW, eDate)
sDate = SELECT dateadd(day, -6, eDate)
END

I try with quation mark in both parameter name and parameter type but still
i get this ERROR.

Thanks in Advance.


Breck Carter [TeamSybase] Posted on 2004-02-23 15:19:14.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: What is rong with this function
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com>
References: <403a1742@forums-2-dub>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: bcarter.sentex.ca
X-Original-NNTP-Posting-Host: bcarter.sentex.ca
Date: 23 Feb 2004 07:19:14 -0800
X-Trace: forums-1-dub 1077549554 64.7.134.118 (23 Feb 2004 07:19:14 -0800)
X-Original-Trace: 23 Feb 2004 07:19:14 -0800, bcarter.sentex.ca
Lines: 43
X-Authenticated-User: TeamPS
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2593
Article PK: 5731

Don't forget the END IF :)

On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel" <bapashree@yahoo.com>

wrote:

>Hi,
>
>I am using Sybase Anywhere 9.0.0(1108)
>
>I create one function in Sybase Central and it gives me error like
>
>[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access
>violation: near 'BEGIN' in ...[BEGIN] ...
>SQLCODE: -131
>SQLSTATE: 42000
>
>Here is the syntax of function:
>
>ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
>DATE)
>BEGIN
> int mDOW = 0;
> mDOW = SELECT DOW(eDate);
>
> if mDOW = 7 THEN
> sDate = SELECT dateadd(day, -6, eDate)
> ELSE
> eDate = SELECT dateadd(day, 7-mDOW, eDate)
> sDate = SELECT dateadd(day, -6, eDate)
>END
>
>I try with quation mark in both parameter name and parameter type but still
>i get this ERROR.
>
>Thanks in Advance.
>

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
Mobile and Distributed Enterprise Database Applications
www.risingroad.com


Chandresh Patel Posted on 2004-02-23 15:36:41.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
References: <403a1742@forums-2-dub> <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com>
Subject: Re: What is rong with this function
Lines: 75
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: ac9b18bd.ipt.aol.com
X-Original-NNTP-Posting-Host: ac9b18bd.ipt.aol.com
Message-ID: <403a1e09@forums-1-dub>
Date: 23 Feb 2004 07:36:41 -0800
X-Trace: forums-1-dub 1077550601 172.155.24.189 (23 Feb 2004 07:36:41 -0800)
X-Original-Trace: 23 Feb 2004 07:36:41 -0800, ac9b18bd.ipt.aol.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2594
Article PK: 5730

Hi,

After made some changes still getting this error:

ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
DATE)
BEGIN
int mDOW = 0;
mDOW = SELECT DOW(eDate);

IF mDOW = 7 THEN
sDate = SELECT dateadd(day, -6, eDate);
ELSE
eDate = SELECT dateadd(day, 7-mDOW, eDate);
sDate = SELECT dateadd(day, -6, eDate);
END IF;
END


Thanks

"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
message news:rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com...
> Don't forget the END IF :)
>
> On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> wrote:
>
> >Hi,
> >
> >I am using Sybase Anywhere 9.0.0(1108)
> >
> >I create one function in Sybase Central and it gives me error like
> >
> >[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access
> >violation: near 'BEGIN' in ...[BEGIN] ...
> >SQLCODE: -131
> >SQLSTATE: 42000
> >
> >Here is the syntax of function:
> >
> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
> >DATE)
> >BEGIN
> > int mDOW = 0;
> > mDOW = SELECT DOW(eDate);
> >
> > if mDOW = 7 THEN
> > sDate = SELECT dateadd(day, -6, eDate)
> > ELSE
> > eDate = SELECT dateadd(day, 7-mDOW, eDate)
> > sDate = SELECT dateadd(day, -6, eDate)
> >END
> >
> >I try with quation mark in both parameter name and parameter type but
still
> >i get this ERROR.
> >
> >Thanks in Advance.
> >
>
> --
> SQL Anywhere Studio 9 Developer's Guide
> Buy the book:
http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> bcarter@risingroad.com
> Mobile and Distributed Enterprise Database Applications
> www.risingroad.com


Breck Carter [TeamSybase] Posted on 2004-02-23 15:39:18.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: What is rong with this function
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com>
References: <403a1742@forums-2-dub> <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com> <403a1e09@forums-1-dub>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: bcarter.sentex.ca
X-Original-NNTP-Posting-Host: bcarter.sentex.ca
Date: 23 Feb 2004 07:39:18 -0800
X-Trace: forums-1-dub 1077550758 64.7.134.118 (23 Feb 2004 07:39:18 -0800)
X-Original-Trace: 23 Feb 2004 07:39:18 -0800, bcarter.sentex.ca
Lines: 89
X-Authenticated-User: TeamPS
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2595
Article PK: 5732

Try "SET mDOW = DOW ( ... );"

You also need a RETURN clause and RETURN statement if you want a
FUNCTION, or change it to a PROCEDURE.

On 23 Feb 2004 07:36:41 -0800, "Chandresh Patel" <bapashree@yahoo.com>

wrote:

>Hi,
>
>After made some changes still getting this error:
>
>ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
>DATE)
>BEGIN
> int mDOW = 0;
> mDOW = SELECT DOW(eDate);
>
> IF mDOW = 7 THEN
> sDate = SELECT dateadd(day, -6, eDate);
> ELSE
> eDate = SELECT dateadd(day, 7-mDOW, eDate);
> sDate = SELECT dateadd(day, -6, eDate);
> END IF;
>END
>
>
>Thanks
>
>
>
>
>
>
>"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
>message news:rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com...
>> Don't forget the END IF :)
>>
>> On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel" <bapashree@yahoo.com>
>> wrote:
>>
>> >Hi,
>> >
>> >I am using Sybase Anywhere 9.0.0(1108)
>> >
>> >I create one function in Sybase Central and it gives me error like
>> >
>> >[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access
>> >violation: near 'BEGIN' in ...[BEGIN] ...
>> >SQLCODE: -131
>> >SQLSTATE: 42000
>> >
>> >Here is the syntax of function:
>> >
>> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
>> >DATE)
>> >BEGIN
>> > int mDOW = 0;
>> > mDOW = SELECT DOW(eDate);
>> >
>> > if mDOW = 7 THEN
>> > sDate = SELECT dateadd(day, -6, eDate)
>> > ELSE
>> > eDate = SELECT dateadd(day, 7-mDOW, eDate)
>> > sDate = SELECT dateadd(day, -6, eDate)
>> >END
>> >
>> >I try with quation mark in both parameter name and parameter type but
>still
>> >i get this ERROR.
>> >
>> >Thanks in Advance.
>> >
>>
>> --
>> SQL Anywhere Studio 9 Developer's Guide
>> Buy the book:
>http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
>> bcarter@risingroad.com
>> Mobile and Distributed Enterprise Database Applications
>> www.risingroad.com
>

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
Mobile and Distributed Enterprise Database Applications
www.risingroad.com


Chandresh Patel Posted on 2004-02-23 15:57:24.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
References: <403a1742@forums-2-dub> <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com> <403a1e09@forums-1-dub> <vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com>
Subject: Re: What is rong with this function
Lines: 111
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: ac9b18bd.ipt.aol.com
Message-ID: <403a22e9@forums-2-dub>
X-Original-Trace: 23 Feb 2004 07:57:29 -0800, ac9b18bd.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 23 Feb 2004 07:56:54 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 23 Feb 2004 07:57:24 -0800
X-Trace: forums-1-dub 1077551844 10.22.108.75 (23 Feb 2004 07:57:24 -0800)
X-Original-Trace: 23 Feb 2004 07:57:24 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2597
Article PK: 5735

Hi Breck,

After changing to SET mDow = dow(eDate) still I am getting this error and I
don't understand Why should i need return close.


What I want is : pass two data parameter in function and change it values
thats why i take INOUT.

Let me know what i have to do with this function.


Thanks.

"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
message news:vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com...
> Try "SET mDOW = DOW ( ... );"
>
> You also need a RETURN clause and RETURN statement if you want a
> FUNCTION, or change it to a PROCEDURE.
>
> On 23 Feb 2004 07:36:41 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> wrote:
>
> >Hi,
> >
> >After made some changes still getting this error:
> >
> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
> >DATE)
> >BEGIN
> > int mDOW = 0;
> > mDOW = SELECT DOW(eDate);
> >
> > IF mDOW = 7 THEN
> > sDate = SELECT dateadd(day, -6, eDate);
> > ELSE
> > eDate = SELECT dateadd(day, 7-mDOW, eDate);
> > sDate = SELECT dateadd(day, -6, eDate);
> > END IF;
> >END
> >
> >
> >Thanks
> >
> >
> >
> >
> >
> >
> >"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> >message news:rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com...
> >> Don't forget the END IF :)
> >>
> >> On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> >> wrote:
> >>
> >> >Hi,
> >> >
> >> >I am using Sybase Anywhere 9.0.0(1108)
> >> >
> >> >I create one function in Sybase Central and it gives me error like
> >> >
> >> >[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access
> >> >violation: near 'BEGIN' in ...[BEGIN] ...
> >> >SQLCODE: -131
> >> >SQLSTATE: 42000
> >> >
> >> >Here is the syntax of function:
> >> >
> >> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
eDate
> >> >DATE)
> >> >BEGIN
> >> > int mDOW = 0;
> >> > mDOW = SELECT DOW(eDate);
> >> >
> >> > if mDOW = 7 THEN
> >> > sDate = SELECT dateadd(day, -6, eDate)
> >> > ELSE
> >> > eDate = SELECT dateadd(day, 7-mDOW, eDate)
> >> > sDate = SELECT dateadd(day, -6, eDate)
> >> >END
> >> >
> >> >I try with quation mark in both parameter name and parameter type but
> >still
> >> >i get this ERROR.
> >> >
> >> >Thanks in Advance.
> >> >
> >>
> >> --
> >> SQL Anywhere Studio 9 Developer's Guide
> >> Buy the book:
> >http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> >> bcarter@risingroad.com
> >> Mobile and Distributed Enterprise Database Applications
> >> www.risingroad.com
> >
>
> --
> SQL Anywhere Studio 9 Developer's Guide
> Buy the book:
http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> bcarter@risingroad.com
> Mobile and Distributed Enterprise Database Applications
> www.risingroad.com


Antonio Arena Posted on 2004-02-23 16:14:16.0Z
From: "Antonio Arena" <antonio.arena@bluserenahotels.it>
Newsgroups: ianywhere.public.general
References: <403a1742@forums-2-dub> <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com> <403a1e09@forums-1-dub> <vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com> <403a22e9@forums-2-dub>
Subject: Re: What is rong with this function
Lines: 144
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: host130-152.pool81117.interbusiness.it
X-Original-NNTP-Posting-Host: host130-152.pool81117.interbusiness.it
Message-ID: <403a26d8@forums-1-dub>
Date: 23 Feb 2004 08:14:16 -0800
X-Trace: forums-1-dub 1077552856 81.117.152.130 (23 Feb 2004 08:14:16 -0800)
X-Original-Trace: 23 Feb 2004 08:14:16 -0800, host130-152.pool81117.interbusiness.it
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2598
Article PK: 5737

Hi Chandresh,

try this:

ALTER PROCEDURE DBA."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
DATE)
BEGIN
DECLARE mDOW INTEGER;

SET mDOW = DOW(eDate);

IF mDOW = 7 THEN
SET sDate = dateadd(day, -6, eDate);
ELSE
SET eDate = dateadd(day, 7-mDOW, eDate);
SET sDate = dateadd(day, -6, eDate);
END IF;
END

Note that if you don't need return values, you must create a PROCEDURE and
not a FUNCTION.

Good luck.

"Chandresh Patel" <bapashree@yahoo.com> ha scritto nel messaggio
news:403a22e9@forums-2-dub...

> Hi Breck,
>
> After changing to SET mDow = dow(eDate) still I am getting this error and
I
> don't understand Why should i need return close.
>
>
> What I want is : pass two data parameter in function and change it values
> thats why i take INOUT.
>
> Let me know what i have to do with this function.
>
>
> Thanks.
>
>
>
> "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> message news:vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com...
> > Try "SET mDOW = DOW ( ... );"
> >
> > You also need a RETURN clause and RETURN statement if you want a
> > FUNCTION, or change it to a PROCEDURE.
> >
> > On 23 Feb 2004 07:36:41 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> > wrote:
> >
> > >Hi,
> > >
> > >After made some changes still getting this error:
> > >
> > >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
eDate
> > >DATE)
> > >BEGIN
> > > int mDOW = 0;
> > > mDOW = SELECT DOW(eDate);
> > >
> > > IF mDOW = 7 THEN
> > > sDate = SELECT dateadd(day, -6, eDate);
> > > ELSE
> > > eDate = SELECT dateadd(day, 7-mDOW, eDate);
> > > sDate = SELECT dateadd(day, -6, eDate);
> > > END IF;
> > >END
> > >
> > >
> > >Thanks
> > >
> > >
> > >
> > >
> > >
> > >
> > >"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> > >message news:rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com...
> > >> Don't forget the END IF :)
> > >>
> > >> On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel"
<bapashree@yahoo.com>
> > >> wrote:
> > >>
> > >> >Hi,
> > >> >
> > >> >I am using Sybase Anywhere 9.0.0(1108)
> > >> >
> > >> >I create one function in Sybase Central and it gives me error like
> > >> >
> > >> >[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or
access
> > >> >violation: near 'BEGIN' in ...[BEGIN] ...
> > >> >SQLCODE: -131
> > >> >SQLSTATE: 42000
> > >> >
> > >> >Here is the syntax of function:
> > >> >
> > >> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
> eDate
> > >> >DATE)
> > >> >BEGIN
> > >> > int mDOW = 0;
> > >> > mDOW = SELECT DOW(eDate);
> > >> >
> > >> > if mDOW = 7 THEN
> > >> > sDate = SELECT dateadd(day, -6, eDate)
> > >> > ELSE
> > >> > eDate = SELECT dateadd(day, 7-mDOW, eDate)
> > >> > sDate = SELECT dateadd(day, -6, eDate)
> > >> >END
> > >> >
> > >> >I try with quation mark in both parameter name and parameter type
but
> > >still
> > >> >i get this ERROR.
> > >> >
> > >> >Thanks in Advance.
> > >> >
> > >>
> > >> --
> > >> SQL Anywhere Studio 9 Developer's Guide
> > >> Buy the book:
> > >http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> > >> bcarter@risingroad.com
> > >> Mobile and Distributed Enterprise Database Applications
> > >> www.risingroad.com
> > >
> >
> > --
> > SQL Anywhere Studio 9 Developer's Guide
> > Buy the book:
> http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> > bcarter@risingroad.com
> > Mobile and Distributed Enterprise Database Applications
> > www.risingroad.com
>
>


Chris Keating (iAnywhere Solutions) Posted on 2004-02-23 16:15:36.0Z
From: "Chris Keating \(iAnywhere Solutions\)" <FightSpam_keating@iAnywhere.com>
Newsgroups: ianywhere.public.general
References: <403a1742@forums-2-dub> <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com> <403a1e09@forums-1-dub> <vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com> <403a22e9@forums-2-dub>
Subject: Re: What is rong with this function
Lines: 180
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: keating-xp.sybase.com
X-Original-NNTP-Posting-Host: keating-xp.sybase.com
Message-ID: <403a2728$1@forums-1-dub>
Date: 23 Feb 2004 08:15:36 -0800
X-Trace: forums-1-dub 1077552936 172.31.141.1 (23 Feb 2004 08:15:36 -0800)
X-Original-Trace: 23 Feb 2004 08:15:36 -0800, keating-xp.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2599
Article PK: 5738

1) You are mixing syntax withn you use SELECT to set the variable. If you
want Watcom syntax, use SET var = {....}
2) The statement "int mDOW = 0" is not valid sql syntax. It should be

declare mDow integer;
set mDow = 0;

3) You delared this as a FUNCTION but you are not RETURNing a value. Declare
this a procedure.

The syntax error that you are getting is due to Point 2, but you will also
likely get a secondary syntax error for Point 3.

Here is the rewritten procedure:

create procedure "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
DATE)
BEGIN
declare mDOW int ;
set mDOW = 0;
SET mDOW = DOW(eDate);

if mDOW = 7 THEN
SET sDate = dateadd(day, -6, eDate);
ELSE
SET eDate = dateadd(day, 7-mDOW, eDate);
SET sDate = dateadd(day, -6, eDate);
END IF
END


--

Chris Keating
Sybase Adaptive Server Anywhere Professional Version 8

****************************************************************************
*
Sign up today for your copy of the SQL Anywhere Studio 9 Developer Edition
and try out the market-leading database for mobile, embedded and small to
medium sized business environments for free!

http://www.ianywhere.com/promos/deved/index.html

****************************************************************************
*

iAnywhere Solutions http://www.iAnywhere.com

** Please only post to the newsgroup

** Whitepapers can be found at http://www.iAnywhere.com/developer
** EBFs can be found at http://downloads.sybase.com/swx/sdmain.stm
** Use CaseXpress to report bugs http://casexpress.sybase.com

****************************************************************************
*

"Chandresh Patel" <bapashree@yahoo.com> wrote in message
news:403a22e9@forums-2-dub...
> Hi Breck,
>
> After changing to SET mDow = dow(eDate) still I am getting this error and
I
> don't understand Why should i need return close.
>
>
> What I want is : pass two data parameter in function and change it values

> thats why i take INOUT.
>
> Let me know what i have to do with this function.
>
>
> Thanks.
>
>
>
> "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> message news:vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com...
> > Try "SET mDOW = DOW ( ... );"
> >
> > You also need a RETURN clause and RETURN statement if you want a
> > FUNCTION, or change it to a PROCEDURE.
> >
> > On 23 Feb 2004 07:36:41 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> > wrote:
> >
> > >Hi,
> > >
> > >After made some changes still getting this error:
> > >
> > >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
eDate
> > >DATE)
> > >BEGIN
> > > int mDOW = 0;
> > > mDOW = SELECT DOW(eDate);
> > >
> > > IF mDOW = 7 THEN
> > > sDate = SELECT dateadd(day, -6, eDate);
> > > ELSE
> > > eDate = SELECT dateadd(day, 7-mDOW, eDate);
> > > sDate = SELECT dateadd(day, -6, eDate);
> > > END IF;
> > >END
> > >
> > >
> > >Thanks
> > >
> > >
> > >
> > >
> > >
> > >
> > >"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> > >message news:rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com...
> > >> Don't forget the END IF :)
> > >>
> > >> On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel"
<bapashree@yahoo.com>
> > >> wrote:
> > >>
> > >> >Hi,
> > >> >
> > >> >I am using Sybase Anywhere 9.0.0(1108)
> > >> >
> > >> >I create one function in Sybase Central and it gives me error like
> > >> >
> > >> >[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or
access
> > >> >violation: near 'BEGIN' in ...[BEGIN] ...
> > >> >SQLCODE: -131
> > >> >SQLSTATE: 42000
> > >> >
> > >> >Here is the syntax of function:
> > >> >
> > >> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
> eDate
> > >> >DATE)
> > >> >BEGIN
> > >> > int mDOW = 0;
> > >> > mDOW = SELECT DOW(eDate);
> > >> >
> > >> > if mDOW = 7 THEN
> > >> > sDate = SELECT dateadd(day, -6, eDate)
> > >> > ELSE
> > >> > eDate = SELECT dateadd(day, 7-mDOW, eDate)
> > >> > sDate = SELECT dateadd(day, -6, eDate)
> > >> >END
> > >> >
> > >> >I try with quation mark in both parameter name and parameter type
but
> > >still
> > >> >i get this ERROR.
> > >> >
> > >> >Thanks in Advance.
> > >> >
> > >>
> > >> --
> > >> SQL Anywhere Studio 9 Developer's Guide
> > >> Buy the book:
> > >http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> > >> bcarter@risingroad.com
> > >> Mobile and Distributed Enterprise Database Applications
> > >> www.risingroad.com
> > >
> >
> > --
> > SQL Anywhere Studio 9 Developer's Guide
> > Buy the book:
> http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> > bcarter@risingroad.com
> > Mobile and Distributed Enterprise Database Applications
> > www.risingroad.com
>
>


Chandresh Patel Posted on 2004-02-23 16:25:29.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
References: <403a1742@forums-2-dub> <rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com> <403a1e09@forums-1-dub> <vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com> <403a22e9@forums-2-dub> <403a2728$1@forums-1-dub>
Subject: Re: What is rong with this function
Lines: 195
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: ac9b18bd.ipt.aol.com
Message-ID: <403a2982@forums-2-dub>
X-Original-Trace: 23 Feb 2004 08:25:38 -0800, ac9b18bd.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 23 Feb 2004 08:25:02 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 23 Feb 2004 08:25:29 -0800
X-Trace: forums-1-dub 1077553529 10.22.108.75 (23 Feb 2004 08:25:29 -0800)
X-Original-Trace: 23 Feb 2004 08:25:29 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2600
Article PK: 5739

Both of you Thank you very much.

It works.


"Chris Keating (iAnywhere Solutions)" <FightSpam_keating@iAnywhere.com>

wrote in message news:403a2728$1@forums-1-dub...
>
> 1) You are mixing syntax withn you use SELECT to set the variable. If you
> want Watcom syntax, use SET var = {....}
> 2) The statement "int mDOW = 0" is not valid sql syntax. It should be
>
> declare mDow integer;
> set mDow = 0;
>
> 3) You delared this as a FUNCTION but you are not RETURNing a value.
Declare
> this a procedure.
>
> The syntax error that you are getting is due to Point 2, but you will also
> likely get a secondary syntax error for Point 3.
>
> Here is the rewritten procedure:
>
> create procedure "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT eDate
> DATE)
> BEGIN
> declare mDOW int ;
> set mDOW = 0;
> SET mDOW = DOW(eDate);
>
> if mDOW = 7 THEN
> SET sDate = dateadd(day, -6, eDate);
> ELSE
> SET eDate = dateadd(day, 7-mDOW, eDate);
> SET sDate = dateadd(day, -6, eDate);
> END IF
> END
>
>
> --
>
> Chris Keating
> Sybase Adaptive Server Anywhere Professional Version 8
>
>
****************************************************************************
> *
> Sign up today for your copy of the SQL Anywhere Studio 9 Developer Edition
> and try out the market-leading database for mobile, embedded and small to
> medium sized business environments for free!
>
> http://www.ianywhere.com/promos/deved/index.html
>
>
****************************************************************************
> *
>
> iAnywhere Solutions http://www.iAnywhere.com
>
> ** Please only post to the newsgroup
>
> ** Whitepapers can be found at http://www.iAnywhere.com/developer
> ** EBFs can be found at http://downloads.sybase.com/swx/sdmain.stm
> ** Use CaseXpress to report bugs http://casexpress.sybase.com
>
>
****************************************************************************
> *
>
> "Chandresh Patel" <bapashree@yahoo.com> wrote in message
> news:403a22e9@forums-2-dub...
> > Hi Breck,
> >
> > After changing to SET mDow = dow(eDate) still I am getting this error
and
> I
> > don't understand Why should i need return close.
> >
> >
> > What I want is : pass two data parameter in function and change it
values
>
> > thats why i take INOUT.
> >
> > Let me know what i have to do with this function.
> >
> >
> > Thanks.
> >
> >
> >
> > "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> > message news:vf7k30dif65lphdeepmi5s8nj6ileg0jqm@4ax.com...
> > > Try "SET mDOW = DOW ( ... );"
> > >
> > > You also need a RETURN clause and RETURN statement if you want a
> > > FUNCTION, or change it to a PROCEDURE.
> > >
> > > On 23 Feb 2004 07:36:41 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> > > wrote:
> > >
> > > >Hi,
> > > >
> > > >After made some changes still getting this error:
> > > >
> > > >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
> eDate
> > > >DATE)
> > > >BEGIN
> > > > int mDOW = 0;
> > > > mDOW = SELECT DOW(eDate);
> > > >
> > > > IF mDOW = 7 THEN
> > > > sDate = SELECT dateadd(day, -6, eDate);
> > > > ELSE
> > > > eDate = SELECT dateadd(day, 7-mDOW, eDate);
> > > > sDate = SELECT dateadd(day, -6, eDate);
> > > > END IF;
> > > >END
> > > >
> > > >
> > > >Thanks
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> > > >message news:rc6k3059dcec4dbu20jt53l70jtmutkaq4@4ax.com...
> > > >> Don't forget the END IF :)
> > > >>
> > > >> On 23 Feb 2004 07:07:36 -0800, "Chandresh Patel"
> <bapashree@yahoo.com>
> > > >> wrote:
> > > >>
> > > >> >Hi,
> > > >> >
> > > >> >I am using Sybase Anywhere 9.0.0(1108)
> > > >> >
> > > >> >I create one function in Sybase Central and it gives me error like
> > > >> >
> > > >> >[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or
> access
> > > >> >violation: near 'BEGIN' in ...[BEGIN] ...
> > > >> >SQLCODE: -131
> > > >> >SQLSTATE: 42000
> > > >> >
> > > >> >Here is the syntax of function:
> > > >> >
> > > >> >ALTER FUNCTION "DBA"."GetCurrentWeekDates"(INOUT sDate DATE, INOUT
> > eDate
> > > >> >DATE)
> > > >> >BEGIN
> > > >> > int mDOW = 0;
> > > >> > mDOW = SELECT DOW(eDate);
> > > >> >
> > > >> > if mDOW = 7 THEN
> > > >> > sDate = SELECT dateadd(day, -6, eDate)
> > > >> > ELSE
> > > >> > eDate = SELECT dateadd(day, 7-mDOW, eDate)
> > > >> > sDate = SELECT dateadd(day, -6, eDate)
> > > >> >END
> > > >> >
> > > >> >I try with quation mark in both parameter name and parameter type
> but
> > > >still
> > > >> >i get this ERROR.
> > > >> >
> > > >> >Thanks in Advance.
> > > >> >
> > > >>
> > > >> --
> > > >> SQL Anywhere Studio 9 Developer's Guide
> > > >> Buy the book:
> > > >http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> > > >> bcarter@risingroad.com
> > > >> Mobile and Distributed Enterprise Database Applications
> > > >> www.risingroad.com
> > > >
> > >
> > > --
> > > SQL Anywhere Studio 9 Developer's Guide
> > > Buy the book:
> > http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> > > bcarter@risingroad.com
> > > Mobile and Distributed Enterprise Database Applications
> > > www.risingroad.com
> >
> >
>
>