Get the Row Number or Row ID

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....
0
Santhanam
2/24/2010 5:35:36 AM
sybase.ase.general 8655 articles. 0 followers. Follow

2 Replies
7790 Views

Similar Articles

[PageSpeed] 49

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....
0
Cory
2/24/2010 7:17:31 AM
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]

0
Bret
2/24/2010 6:40:30 PM
Reply:

Similar Artilces:

How to set the row number and get the row number for ("selected row) in Datagrid
I face a problem that i can't get the selected row of the datagrid in both server side script (VB.net) and client side script (javascript) As i can't use the button column / hyperlink column in the datagrid. Thus , i need to handle the change the background color of the selected row and also to get the selected row number for Update/Delete. Thanks in advance. This depends on how do you perform the selection. Do you want to implement chaning of the SelectedRow at the client side without any postback? If you have no issues with postback, then you can do s little trick here: 1. ...

The row number and offset of each row in the page should have a matching entry in row number table
Is the proper correction for the following to recreate the table BCPout/IN or table to table insert, or just drop and recreate the index? Row number is 0. Is there a way to correct just the data page? Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row...

how to get id of row from check box in gridview row
this is my gridview code   <asp:GridView ID="dgAssociatedAttributes" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Width="80%"> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> <Columns>           <asp:Bound...

Returning n rows, setting start row, total number of rows
Hi, I'm try to find out how ado.net can perform some of the things i am able to do in ado. Here is the scenario: I will be searching a table that may have 1000's of rows. I want to be able to dictate how many rows (page size) to return and what the starting row number is and be able to find out how many total rows would be returned by the query. Using old ado recordsets I was able to get the recordset and get the count or all the rows (.recordcount - ormaybe it was .rowcount) and then jump to the starting position (.absoluteposition). How can I do the equivalent in .net? From loo...

Get the last inserted row's Identity (ID) using DataTable and Row
 hiI use DataTable and Row and the Update() method to insert data into my table.I need to retrieve the Identity (ID) assigned to that row for further processing. (e.g. add data into other tables that refer to this row).How do I retrieve the ID?  In a high traffic website (e.g. 100 inserts in 5 seconds), by just retrieving the ID of the last inserted row may not be very safe. Please advise if I am correct.Any other methods of achieving the same goal?thanks in advance  string query = "Insert Into yourTableName("col1","col2") values(xyz,pqr) select...

First Row, Next Row, Prior Row, Last Row
I have a SQL Anywhere 7.0 Database, have a table Product_detail which contains Column Name Datatype width Null Default batch_id char(10) No None prod_id Integer No None employee_id Integer No None quantity Integer No None price Numeric (14, 2) No None Its primary key is batch_id I have a Freeform Datawindow with this table I want to provide the first row, next row, prior row and last row Ho...

Get row index of found row
How do I find the row index after searching a Dataset Table? For example, <code> Dim recId As String = Request.QueryString("r") Dim r As DataRow Dim tbl As DataTable = ds.Tables("drivers") tbl.PrimaryKey = New DataColumn() {tbl.Columns("recId")} If NOT IsNothing(tbl.Rows.Find(recId)) Then                r = tbl.Rows.Find(recId) End If </code> Next, I want to know the row index of the row, r, so the user can move foward and back, from this point, through the rows in the table, in order to display the next record in the table or the previous record in the table.http://www.pageforwarddesign.com I see find as the only mechanism that searches for you; otherwise, loop through each row. BrianBrian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). I must not have made my question clear. Once found, a datatable row corresponds to a row index in the datatable, such as tbl.row(10) where 10 is the row index. I want to know the index, into the datatable, of the row that has just been found.http://www.pageforwarddesign.com...

How to get data from database row by row
I try to get data from a database row by row, I am using DataReader, the return result is not I expected, don't know how to solve it. Here is my sample code: --------------------------------------------Dim commandText As String = "select * from customer "Dim con As New OleDbConnection("Data Source=c:\company.mdb;Persist Security Info=False; Provider=Microsoft.Jet.OLEDB.4.0;")Dim Cmd As New OleDbCommand(commandText, con)Dim reader As OleDbDataReader = Cmd.ExecuteReader()             Using con       &nbs...

gridview row numbers or row count
In my gridview I want to display the number for each row, so this column doesn't have any relation with any datasource. I want it to display the number of row that it represents, so if I delete a row it still has count and represents the right number of rows that I have in my gridview. Any suggestions are welcome also. I think this thread might have what you're looking for: http://forums.asp.net/p/992655/1292440.aspxMike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/...

getting the number of rows...
how can you get the number of rows in query resault with out filling dataset and checking the "count"? afaik - you can't - - you've got to have an entity to count the rows - the dataset is the 'finished product' that contains the result of your query - until you've queried and received the data from the database, you don't know how many rows you've receivedDavid WierMCP/ASPInsiderASPNet101.com - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as ...

How do I get the row number?
I have tryed to find a way to include the row number in a querry but without result. I have a table select some rows ordered and now I will add a column called rank How do I get the rownumber in the field rank ? Thanks in advance Jan O Jan O www.olsmar.com The way I'd suggest assigning a row number to your resultset is to INSERT your resultset into a temporary table or table variable which has an IDENTITY column, something like this: -- set up a table variable to hold the resultset DECLARE @myTable (Rank int identity(1,1) primary_key, ColumnA va...

get number from row
if i have a this string to select a row from database of acess: select TOP 1 * from odkazy how i elicit from it id column? i need know id from select row then just get the id... select top 1 id from odkazy... PS..you would need an order by clause in the select statement otherwise the TOP has no meaning.. hth***********************Dinakar NethiLife is short. Enjoy it.*********************** my problem: (for example) if i have 5 columns with numbers in select row and i want display cast of this numbers I write: one = ds.tables("Odkazy").Rows(i)("...

How do you get the number of rows
I have a gridview and I want to display the total number of rows of data like 5000 rows? This is not the same as the GridView1.Rows.Count, which gives the number of rows being displayed like 10 of 5000 rows. How do I get at the total? Hi, i think what you are asking is how to get the number of rows of the bounded dataset. Lets say you bound a dataset to the grid, you only need to get the number of rows of the first table in the dataset: myDataset.tables(0).rows.count As simple as that!   regards, njs That works in ASP.NET 1.x That doesn't work in ASP.NET 2.0s gridview unless I am missing something You need to count the rows from the DataSource! HighOnCodingWanna get high! You mean loop through the records incrementing a counter? That means passing throught the results twice. Once to display the in a gridview and once to count the rows. Never had to do this in past versions. I don't think Microsoft would make you do this. Isn't there a better way??? Hi, I was playing with the SqlDataSource control last weekend and saw it can be done in the Selected event. This is completely out of my head but please try this: e.AffectedRows    where e is of type SqlDataSourceStatusEventArgs Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. If your data is comming from Database and I assume it is then you can write a simple query that returns the total number of rec...

Getting the focus row to follow the selected row..
These days I've been looking for solutions to the simpler, less critical but annoying problems. One that my users have noticed is that if they select a row (by clicking on a column in that row) my application will select the row and the focus moves to the column they clicked in the row. However, if the user clicks somewhere that isn't a column but is still in the detail band area for that row, my application will select the row, but the focus will remain on the column and row that it did previously. Is there a way to get the focus to follow the selected row? Thanks in advance...

Find the row number on click of a gridview row???
Hello everyone,I need to find the gridview row number on click of a row on Page_load not on any other event..!! How do i do that?Please help me..!!regards,Francis P. Ferns Sorry Francis, but I believe you're out of luck as the Page.Load event is way too early in the Page lifecyle to pick this up. This would most likely be done in the SelectedIndexChanged, RowCommand, or Click event of a Button.Thanks, EdMicrosoft MVP - ASP/ASP.NET Hi,Ya i understand that. Is there any other way i can find out the Row number.I ll tell you my actual requirement.Im implementing the ICallbackEventHa...

How do i get one row if the resultset returned has no rows.
Hi I have couple of CTE's which i want to ultimately insert into a temp table... and based on my condition some of the CTE's return some rows and some dont... but i want to have the CTE return atleast one row if there is no data in it.. I have tried doing the following but i am not getting the desired output    ;with cte_rpt4 as (select '4' a,recd_dt as approve_dt, prov_no, prov_name, client_id, claim_mst_id, claim_adj_id, claim_dt, claim_amt, rpt4, (Select count(distinct(Claim_mst_Id)) as crpt4 from #temp1 where datediff(day,isnull(recd_dt,create_dt),isnull(c...

Need to get row id after insert. Can't get my syntax working.
 Hi,I'm trying to get the identity of the row after an insert, but I can't get the syntax right.  Could someone with better eyeballs help me out? Here is my Insert stuff..  <asp:SqlDataSource ID="SqlDataSourceQueue" runat="server" ConnectionString="<%$ ConnectionStrings:ServiceQConnectionString %>" SelectCommand="SELECT * FROM [queue] WHERE ([caseno] = @caseno)" DeleteCommand="DELETE FROM [queue] WHERE [id] = @id" InsertCommand="INSERT INTO queue (caseno...

how to get inserted row id
Hi, I have a table where id is primary key and autonumber. When I insert record to this table I need to get this id. in MSSQL it is very easy to achive with @@Identity feature. But how can I achive similar effect in access db.Ireland's classifieds | UK classifieds The same way. http://support.microsoft.com/?id=232144 INFO: Jet OLE DB Provider Version 4.0 Supports SELECT @@Identity Cheers Ken...

accessing row by row
first of all sorry if i posted this in a wrong place but i'm new to powerbuilder and i have to develop a program quite quickly ( i only worked with acces until now) i have been provided a excel spreadsheet that contains all coloms and rows from all tables wich i have to insert in a database. The difficulty is that i can't use a datapipeline because i need to use a string function to check in wich table i have to put it: TABLENAME_COLUMNNAME -> i thought about using the string function to find out the right column in the right database. however i don't know how you ...

How to get rowcount or row number
Hello, Sybase experts, I have a table, when I select it I want to display row number as well. E.g. Table T1(c1,c2) c1 c2 --- --- aaa bbb ppp qqq fff ggg .... I want to get results like this: rowno c1 c2 ----- --- --- 1 aaa bbb 2 ppp qqq 3 fff ggg .... If I use: select rowno=@rowcount,c1,c2 from T1 I will get: rowno c1 c2 ----- --- --- 0 aaa bbb 0 ppp qqq 0 fff ggg .... Which is NOT what I want, but how can I do that ? Thank you very much Albert ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp Answered in sybase.public.ase.administration. Please don't post the same question to multiple sybase.public.ase.* newsgroups, just pick the one most appropriate newsgroup and post there. -bret Albert wrote: > Hello, Sybase experts, > > I have a table, when I select it I want to display row number as well. > E.g. Table T1(c1,c2) > c1 c2 > --- --- > aaa bbb > ppp qqq > fff ggg > ... > > I want to get results like this: > rowno c1 c2 > ----- --- --- > 1 aaa bbb > 2 ppp qqq > 3 fff ggg > ... > > If I use: > select rowno=@rowcount,c1,c2 > from T1 > > I will get: > rowno c1 c2 > ----- --- --- > 0 aaa bbb > 0 ppp qqq > 0 fff...

How to get a row number in DDDW
Hi, All, When a DDDW on a column opens for the user to pick an item, and when the user clicks on a row or scrolls up/down in the DDDW, is there any way to get the row number of the DDDW? I have tried this in PB 5, and it did not seem to work. Any ideas about PB 6.5 or PB 7.0? Thanks in advance. Ben You can't directly get the row that the user clicked on. You can write code in the ItemChanged event of the parent DW where you get the data value on the parent column, get a handle to the child DW, then perform a Find ( ) on the child DW looking the the data value in the rel...

retrieving from row # to row #.
I have over 750 000 rows to retrieve from a table using a datawindow, but my system can only handle approx 30 000 rows and I would like to start from the end of the table. Is it possible to set the row numbers to retrieve? For example, start the retrieve from row 750 000 and stop at row 720 000. There must be a way. thanks, Vern what backend are you using? <Vern> wrote in message news:6BA241541AAD7F2F0063357385256C40.0063358685256C40@webforums... > I have over 750 000 rows to retrieve from a table using a datawindow, but > my system can only handle approx 30 ...

Getting the number of Rows (Records)
How do I get and return the number of rows (records) in a sql 2005 database, Some code samples would be helpful Thanks Joe   Hi, that would be something like this: select count(*) from yourTable The * can also be replaced by a columnname but since I didn't know your table structure I used * in the example. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Ok, guys this isn't going to work. Take a look at my code. I need it to return the current record that was inserted. Is there a was to do that &n...

Getting row number from SelectedIndexChanged??
Hello, now, I have 2 template columns, the first is a hyperlink column that consist of userno, the next is the gender which is represented by a radiobuttonlist. The radiobuttonlist fire up a method when somebody clicks on or change the selected one: Protected Sub SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim objItem As DataGridItem Response.Write(CType(DataGrid1.Items.Item(DataGrid1.SelectedIndex).FindControl("hl_oNo"), HyperLink)) End Sub I need to read the userno from the hyperlink column so that the...

Web resources about - Get the Row Number or Row ID - sybase.ase.general

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

MLB.com at Bat update brings a number of new features for iPad users
... has finally begun for Major League Baseball. And to celebrate, the popular MLB.com at Bat app has just received a nice update with a number ...

Famous astronaut Scott Kelly is about to come home — here are 8 epic numbers about his record-breaking ...
... 200 gallons of recycled urine and sweat and traveled over 140 million miles, according to The New York Times . Here are some more extreme numbers ...

Look beyond number of moles to catch deadly melanoma
Counting the number of moles on your body may not be the most reliable sign of skin cancer risk, according to new research

Trading casino stocks on Macau numbers
After Macau posted better-than-expected monthly gambling revenue Tuesday, some traders contended that Wynn Resorts could rise.

By the numbers: Mystery of what spring training stats mean
Baseball is back with spring training games starting up. But, do the stats really matter or are they irrelevant? It depends on who you look at. ...

Will Fitbit’s ‘magic number’ really step up your fitness game?
Fitbit reported its best-ever holiday sales this week, but investors are fretting because the wearable maker’s guidance for the current quarter ...

Numbers Don't Lie: India's lower middle order isn't providing the necessary late-innings thrust - Cricket ...
The lower middle order isn't providing the final push for a big total towards the end of the innings

Bugatti Chiron numbers generator: 1,500
The Chiron is a supercar to top all supercars to date. Also, technology to keep the driver from getting lost.

Resources last updated: 3/2/2016 9:30:54 PM