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.

Get the Row Number or Row ID

3 posts in General Discussion Last posting was on 2010-02-24 18:40:30.0Z
Santhanam P Posted on 2010-02-24 05:35:36.0Z
Sender: 1c83.4b828b77.1804289383@sybase.com
From: Santhanam P
Newsgroups: sybase.public.ase.general
Subject: Get the Row Number or Row ID
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4b84baa8.6faf.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 23 Feb 2010 21:35:36 -0800
X-Trace: forums-1-dub 1266989736 10.22.241.41 (23 Feb 2010 21:35:36 -0800)
X-Original-Trace: 23 Feb 2010 21:35:36 -0800, 10.22.241.41
Lines: 6
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28993
Article PK: 78234

Hi,
I am using Sybase Central v4.3 with Interactive SQL to query
the SQL Commands. My concern is how to get the rownumber or
row id in select queries. Is there any in built commands in
the ASE. If not please suggest me how to get the rownumber.
Thanks....


Cory Sane [TeamSybase] Posted on 2010-02-24 07:17:31.0Z
From: "Cory Sane [TeamSybase]" <cory!=sane>
Newsgroups: sybase.public.ase.general
References: <4b84baa8.6faf.1681692777@sybase.com>
In-Reply-To: <4b84baa8.6faf.1681692777@sybase.com>
Subject: Re: Get the Row Number or Row ID
Lines: 14
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6002.18005
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18005
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b84d28b$1@forums-1-dub>
Date: 23 Feb 2010 23:17:31 -0800
X-Trace: forums-1-dub 1266995851 10.22.241.152 (23 Feb 2010 23:17:31 -0800)
X-Original-Trace: 23 Feb 2010 23:17:31 -0800, vip152.sybase.com
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28994
Article PK: 78231

Unless i'm mistaken, ASE does not use a rowid... it can have a timestamp, but it is updated with every modification to the row.
http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/html/blocks/blocks34.htm

--
Cory Sane
[TeamSybase]
Certified Sybase Associate DBA for ASE 15.0

"Santhanam P" wrote in message news:4b84baa8.6faf.1681692777@sybase.com...
> Hi,
> I am using Sybase Central v4.3 with Interactive SQL to query
> the SQL Commands. My concern is how to get the rownumber or
> row id in select queries. Is there any in built commands in
> the ASE. If not please suggest me how to get the rownumber.
> Thanks....


Bret Halford Posted on 2010-02-24 18:40:30.0Z
From: Bret Halford <bret@sybase.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Get the Row Number or Row ID
References: <4b84baa8.6faf.1681692777@sybase.com>
In-Reply-To: <4b84baa8.6faf.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b85729e$1@forums-1-dub>
Date: 24 Feb 2010 10:40:30 -0800
X-Trace: forums-1-dub 1267036830 10.22.241.152 (24 Feb 2010 10:40:30 -0800)
X-Original-Trace: 24 Feb 2010 10:40:30 -0800, vip152.sybase.com
Lines: 53
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28997
Article PK: 78236


On 2/23/2010 10:35 PM, Santhanam P wrote:
> Hi,
> I am using Sybase Central v4.3 with Interactive SQL to query
> the SQL Commands. My concern is how to get the rownumber or
> row id in select queries. Is there any in built commands in
> the ASE. If not please suggest me how to get the rownumber.
> Thanks....

There is no rownumber concept per se (although the DOL lock
scheme has a concept of a fixed row id, which consists of
the combination of page number and row number on the page -
but isn't particularly useful for most query-writers and isn't
directly exposed to the users anyway).

If you want a row number value in your result set, one way
to accomplish it is to select the result set into a work table
adding a "rownum = identity(10)" clause. ("rownum" being an
arbitrary column name and "10" an arbitrary precision).

example:



4> select rownum = identity(3), name into #myresults from systypes
5> go
(46 rows affected)
1> select * from #myresults
2> go
rownum
name


------
---------------------------------------------------------------
------------------------------------------------------------------------
------------------------
1
bigdatetime


2
bigdatetimen


3
bigint


4
bigtime

[snip]