on 2011 Dec 08 10:39 AM
We are using SQL Anywhere 11.0.1.2427 for our tablet users and Oracle 10g for our desktop users. The application is .Net application. We tried to have much common code as possible for the application against SQL Anywhere and application against Oracle. Is there a way to create a SQL Anywhere special value rownum to be equivalent to Oracle rownum? In SQL Anywhere, identity(#) can be used, but it is a function. My thought is to create a special value rownum, the inside of logic for rownum is to call identity(#). Any suggestion or input will be very helpful.
As Chris stated, ROWNUM in Oracle is a pseudocolumn, not a function. The closes function in SQL Anywhere that matches the semantics of ROWNUM is the ROWID() function:
http://dcx.sybase.com/index.html#1201/en/dbreference/rowid-function.html*d5e23698
which returns the row identifer of the row. Caution should be used when using ROWID(), however, because its value is not immutable and a row's identifier can be reused if a row is deleted or moved (in the latter case, for example, through a REORGANIZE statement). Consequently, we do not recommend the use of ROWID() in production situations, but only its use as a diagnostic tool.
SQL Anywhere 11.0.1 supports AUTOINCREMENT columns that can be used in a way similar to what ROWNUM gives you, the major difference is that an AUTOINCREMENT column is a real column making up the schema of the table, whereas in Oracle the ROWNUM pseudocolumn is not part of the table's schema.
In version 12, SQL Anywhere introduced support for SEQUENCEs (which are also supported by Oracle) as a more flexible method to create numeric surrogate keys. A SEQUENCE column, like an AUTOINCREMENT one, is also a real column and not a pseudocolumn.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The equivalent to rownum is the NUMBER function (or the equivalent IDENTITY function) or the ROW_NUMBER function.
See http://dcx.sybase.com/index.html#1101/en/dbreference_en11/number.html for information about the NUMBER function.
See http://dcx.sybase.com/index.html#1101/en/dbusage_en11/ug-olap-s-51258147.html*d5e25328 for info about ROW_NUMBER function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For example, I have created Microsoft Assess equavilent InStr function in Sybase for our application to keep using InStr function with expected result like in Access.
CREATE FUNCTION asp.InStr(
/
FUN: asp.InStr
PKG: ASPEN_SYS_PKG
This function maps the MS-Access INSTR() to SQL Anywhere LOCATE()
*/
in inStringToSearch long varchar,
in inStringToSearchFor long varchar,
in inStringToPosition integer default 0 )
returns integer
not deterministic
begin
return LOCATE(inStringToSearch,inStringToSearchFor,inStringToPosition)
end
I need a special value ROWNUM in Sybase to have same functionality of Oracle in order for application code staying same.
User | Count |
---|---|
68 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.