简体   繁体   English

从1到n获取Progress OpenEdge数据库中的rowid

[英]Get rowid in Progress OpenEdge database from 1 to n

The JDBC driver does not support ROW_NUMBER function. JDBC驱动程序不支持ROW_NUMBER函数。 How can I get the row id from 1 to n when reading data from a table? 从表中读取数据时,如何从1到n获取行ID?

If I have a table with 2 columns as firstname and lastname, then I run a query like "SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS rowid, * FROM tableName" in SQL Server. 如果我有一个包含2列作为名字和姓氏的表,则在SQL Server中运行一个查询,例如“ SELECT ROW_NUMBER()OVER(ORDER BY(SELECT NULL))AS rowid,* FROM tableName”。 That will give me the rowid from 1 to n along with the contents of firstname and lastname in the ResultSet. 这将给我从1到n的rowid以及ResultSet中firstname和lastname的内容。

So I will get a result like: 所以我会得到类似的结果:

1, Felix, Cao 1,费利克斯·曹

2, Jack, Chan 2,杰克·陈

3, Nick, Ho 3,何浩

I want to do a similar query for the OpenEdge database so I can get the rowid in the order like above. 我想对OpenEdge数据库进行类似的查询,以便可以按上述顺序获取rowid。

No, there is no equivalent to ROW_NUMBER in an OpenEdge database. 不,在OpenEdge数据库中没有等效于ROW_NUMBER的信息。

http://knowledgebase.progress.com/articles/Article/Is-ORACLE-row-number-function-supported-in-OpenEdge http://knowledgebase.progress.com/articles/Article/Is-ORACLE-row-number-function-supported-in-OpenEdge

Regarding ROWID: 关于ROWID:

Setting aside the discussion of whether or not it is a good idea to think of ROWIDs as integers... (you should re-read the linked kbase) 撇开将ROWID视为整数是一个好主意的讨论...(您应该重新阅读链接的kbase)

There is no guarantee that any particular ROWID value will ever exist and there is no reason why ROWIDs should start with zero or one or any other value. 不能保证任何特定的ROWID值都将存在,也没有理由为什么ROWID应该以零或一个或任何其他值开头。

If your thought is that ROWIDs and RECIDs are sort of the same and RECIDs are integers consisting of a block# and a position within that block, ROWID 0 is still never going to exist because the first portion of a storage area is control data -- no rows are stored there. 如果您认为ROWID和RECID有点相同并且RECID是由块号和该块中的位置组成的整数,则ROWID 0仍然永远不会存在,因为存储区的第一部分是控制数据-没有行存储在那里。

You can successfully scan a table using guesses for ROWIDs or RECIDs (or by enumerating every possible value) but you have to be prepared to deal with gaps. 您可以使用猜测的ROWID或RECID来成功扫描表(或通过枚举每个可能的值),但是您必须准备好处理差距。 This can be useful, for instance, when trying to recover data from a corrupted db. 例如,在尝试从损坏的数据库中恢复数据时,此功能很有用。 But it isn't something that one would normally do. 但这不是人们通常会做的事情。

I think you have decided that ROWID is the solution to a problem that you are having but that the real problem is not "how to get ROWID 0". 我认为您已决定ROWID是您遇到的问题的解决方案,但真正的问题不是“如何获得ROWID 0”。 If I had to guess I would guess you are perhaps trying to get a result set in batches of N. In that case you should look at this: How to mimic SELECT ... LIMIT, OFFSET in OpenEdge SQL? 如果我不得不猜测,也许您正在尝试以N批为单位获取结果集。在这种情况下,您应该查看以下内容: 如何在OpenEdge SQL中模拟SELECT ... LIMIT,OFFSET?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM