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.

Select Distinct in Sybase 11.2

5 posts in Product Futures Discussion Last posting was on 2002-05-06 20:40:06.0Z
Vijay_Gore Posted on 2002-04-30 16:28:45.0Z
From: Vijay_Gore
Date: Tue, 30 Apr 2002 12:28:45 -0400
Newsgroups: sybase.public.ase.product_futures_discussion
Subject: Select Distinct in Sybase 11.2
Message-ID: <B25F2FBB89929246005A85E785256BAB.005A860F85256BAB@webforums>
Lines: 19
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:512
Article PK: 93682

Hi,
I am trying to fetch a distinct value in a variable.
Sybase does not allow me to use distinct. It
does not give me any error if I remove distinct.

If it has to return
multiple result set it will just populate
the variable with the last returned value.
E.g. It does not allow me to write in a stored proc.
select @var = distinct table.column from table

and if I remove the keyword distinct it compiles but
populates the last value returned in the resultset.
I know the workarounds could be "set rowcount 1" or cursors.
But Oracle would not allow this kind of assignment if
right hand side returns more than one row.

Any insights?
Thanks,


AAA Posted on 2002-05-06 20:40:06.0Z
From: aaa
Date: Mon, 6 May 2002 16:40:06 -0400
Newsgroups: sybase.public.ase.product_futures_discussion
Subject: Re: Select Distinct in Sybase 11.2
Message-ID: <1B9B70C36BF3D028007188E785256BB1.005DFF9885256BAB@webforums>
References: <B25F2FBB89929246005A85E785256BAB.005A860F85256BAB@webforums>
Lines: 2
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:501
Article PK: 93670

Try
select distinct @var = table.column from table


Bret Halford Posted on 2002-04-30 16:51:46.0Z
Message-ID: <3CCECBA2.A1F319C@sybase.com>
Date: Tue, 30 Apr 2002 10:51:46 -0600
From: Bret Halford <bret@sybase.com>
Organization: Sybase, Inc.
X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Re: Select Distinct in Sybase 11.2
References: <B25F2FBB89929246005A85E785256BAB.005A860F85256BAB@webforums>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.ase.product_futures_discussion
Lines: 24
NNTP-Posting-Host: 157.133.80.180
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:511
Article PK: 93681

Could you explain a little more on why you want to use distinct
in this context? Regardless of whether it were allowed or not,
ASE should still populate the variable with the last returned value...


-bret

Vijay_Gore wrote:
>
> Hi,
> I am trying to fetch a distinct value in a variable.
> Sybase does not allow me to use distinct. It
> does not give me any error if I remove distinct.
>
> If it has to return
> multiple result set it will just populate
> the variable with the last returned value.
> E.g. It does not allow me to write in a stored proc.
> select @var = distinct table.column from table
>
> and if I remove the keyword distinct it compiles but
> populates the last value returned in the resultset.
> I know the workarounds could be "set rowcount 1" or cursors.
> But Oracle would not allow this kind of assignment if
> right hand side returns more than one row.
>
> Any insights?
> Thanks,


Vijay_Gore Posted on 2002-04-30 20:29:42.0Z
From: Vijay_Gore
Date: Tue, 30 Apr 2002 16:29:42 -0400
Newsgroups: sybase.public.ase.product_futures_discussion
Subject: Re: Select Distinct in Sybase 11.2
Message-ID: <5940F63CBEA912A40070955B85256BAB.0060D62785256BAB@webforums>
References: <B25F2FBB89929246005A85E785256BAB.005A860F85256BAB@webforums> <3CCECBA2.A1F319C@sybase.com>
Lines: 10
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:510
Article PK: 93680

Thanks for the response Bret.
The database here is designed is such a way that I might find
multiple rows giving out the same column value.
I know that Sybase would assign the last fetched value,
which in either case is correct.
My question is why can't I use distinct?
Is Sybase suppose to generate a run time error?


Thank you


Roger Broadbent Posted on 2002-05-01 11:45:45.0Z
From: "Roger Broadbent" <RBroadbent@wilco-int.excise-this.com>
References: <B25F2FBB89929246005A85E785256BAB.005A860F85256BAB@webforums> <3CCECBA2.A1F319C@sybase.com> <5940F63CBEA912A40070955B85256BAB.0060D62785256BAB@webforums>
Subject: Re: Select Distinct in Sybase 11.2
Date: Wed, 1 May 2002 12:45:45 +0100
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Message-ID: <uHyyldQ8BHA.238@forums.sybase.com>
Newsgroups: sybase.public.ase.product_futures_discussion
NNTP-Posting-Host: wilcohost-180.wilco-int.com 212.36.174.180
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:509
Article PK: 93674

DISTINCT must come directly after the SELECT, or within an aggregate
expression. Your placement of the keyword after the equals sign is illegal,
resulting in a syntax error.

Quite what this has to do with product futures, I'm not sure...

--
Roger Broadbent
Technical Consultant
Wilco International Ltd

NOTE: Anti-Spam measures taken due to excessive spam levels generated
recently through this newsgroup.

<Vijay_Gore> wrote in message
news:5940F63CBEA912A40070955B85256BAB.0060D62785256BAB@webforums...
> Thanks for the response Bret.
> The database here is designed is such a way that I might find
> multiple rows giving out the same column value.
> I know that Sybase would assign the last fetched value,
> which in either case is correct.
> My question is why can't I use distinct?
> Is Sybase suppose to generate a run time error?
>
>
> Thank you