从 Progress OpenEdge 数据库中的表中获取前 100 条记录(例如 SELECT TOP 100..)

发布于 2024-12-08 12:19:36 字数 191 浏览 0 评论 0原文

如何从 Progress OpenEdge 数据库的表中获取有限数量的记录?

就像 SQL 中的那样:

SELECT TOP 100 * FROM MyTable

我能找到的唯一丑陋的解决方案是循环遍历所有记录,并在显示 100 条记录时中断。但感觉应该有一些更好的方法来做到这一点。

How can I get a limited number of records from the table in Progress OpenEdge database?

Something like in SQL:

SELECT TOP 100 * FROM MyTable

The only ugly solution I can find is looping through all records and breaking when 100 of them were displayed. But feels like there should be some better way of doing it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

惜醉颜 2024-12-15 12:19:36

如果您使用 4GL,您可能还需要考虑使用 OPEN QUERY 和 MAX-ROWS 来获得您正在寻找的结果。下面显示了带有计数器的传统 FOR EACH 循环,以及带有 MAX-ROWS 的 QUERY:

define variable i as integer no-undo.
define frame a with 10 down.

for each customer no-lock break by name:
  i = i + 1.
  display i custNum name discount.
  if i >= 5 then leave.
end.

define query q for customer scrolling.

open query q for each customer no-lock break by name max-rows 5.

do i = 1 to 5 with frame a:
  get next q.
  display i custNum name discount.
end.

If you are using the 4GL you might also want to look at using OPEN QUERY and MAX-ROWS to achieve the result that you are looking for. The following shows a traditional FOR EACH loop with a counter and then a QUERY with MAX-ROWS:

define variable i as integer no-undo.
define frame a with 10 down.

for each customer no-lock break by name:
  i = i + 1.
  display i custNum name discount.
  if i >= 5 then leave.
end.

define query q for customer scrolling.

open query q for each customer no-lock break by name max-rows 5.

do i = 1 to 5 with frame a:
  get next q.
  display i custNum name discount.
end.
荒路情人 2024-12-15 12:19:36

如果您使用的是 SQL-92 引擎,则类似于:

SELECT TOP 100 FROM pub.customer;

应该可以正常工作。

如果您使用 4GL 引擎,那么您不应该尝试将 SQL 与 4GL 混合。它只会导致痛苦、不幸和痛苦。 4GL 不是 SQL。很久以前,出于营销原因,有一些 SQL-89 语句被放入 4GL 中。尝试使用它们会导致严重的情感创伤。你已被警告过。

If you are using the SQL-92 engine then something like:

SELECT TOP 100 FROM pub.customer;

should work just fine.

If you are using the 4GL engine then you should not be attempting to blend SQL with 4GL. It will only lead to pain, misery and agony. The 4GL is not SQL. There are a few SQL-89 statements that were put in the 4GL a long, long time ago for marketing reasons. Trying to use them will result in severe emotional trauma. You have been warned.

浅忆流年 2024-12-15 12:19:36

请点击链接下载该文件。希望问题能得到解答
<一href="http://www.google.com.ph/url?sa=t&source=web&cd=2&ved=0CCEQFjAB&url=http://documentation.progress.com/output/OpenEdge102b/pdfs /dmadm/dmadm.pdf&r ct=j&q=limit%20records%20on%20OpenEdge%20database&ei=UJWOTt-NLsSpiAenxtX5DQ&usg=AFQjCNE4InbmJPEZmkWVLExrkDsecVa3-w&sig2=UDUc6TUw2yKer58TQP4GFA&cad=rja" rel="nofollow">OpenEdge 数据库

Please follow the link to download the file. Hoping that the question will answer on it
OpenEdge Database

烟燃烟灭 2024-12-15 12:19:36

将变量 i 定义为整数不可撤消。

对于宽度为 320 的每个客户无锁:

ASSIGN i = i + 1.

如果 i <= 100 那么
DISP CustNum 地址 余额 城市 联系方式
国家信用限额折扣
姓名 电话 邮政编码 销售代表 州条款 。

结尾。

DEFINE VARIABLE i AS INTEGER NO-UNDO.

FOR EACH customer NO-LOCK with width 320:

ASSIGN i = i + 1.

if i <= 100 then
DISP CustNum Address Balance City Contact
Country CreditLimit Discount
Name Phone PostalCode SalesRep State Terms .

END.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文