Sybase IQ 分页

发布于 2024-07-24 23:59:29 字数 534 浏览 6 评论 0原文

我想知道是否有人能解决以下要求。 我有一个存储过程,它返回一个结果集,例如 1000 行。 现在我需要将其限制为一次 100 行。 因此,我将传入开始索引值和结束索引值,并且我只想要开始索引行计数和结束索引行计数之间的记录

因此,例如我的存储过程调用签名如下所示:-

stp_mystoredproc(startIndex INTEGER, endIndex INTEGER)

因此,如果我设置 startIndex = 100endIndex = 200 然后我希望存储过程返回 1000 总重置集中第 100 到 200 行中的记录。

我的第一次尝试是将结果集放入临时表中带有标识列的表,然后根据标识选择我需要的范围,但这有点慢。 我知道 Oracle 支持分页,因此您可以对结果集进行分页。 有人知道 Sybase IQ(v12.6 或 v12.7)是否支持类似的功能?

最终目标是对整个结果集(1000 条记录)进行分页,但一次分页 100 行。

I wonder if anyone has a solution to the following requirement. I have a stored procedure which returns a result set of for example 1000 rows. Now I need to limit this to 100 rows at a time. So I will pass in a start and end index value and I only want the records between the start index rowcount and the end index rowcount

So for example my stored procedure call signature looks like this:-

stp_mystoredproc(startIndex INTEGER, endIndex INTEGER)

So if I set startIndex = 100 and endIndex = 200 then I want the stored procedure to return the records in rows 100 to 200 out of the total reset set of 1000.

My first attempt is put the result set in a temp table with an identity column then select based on the identity the range I need but this is somewhat slow. I know Oracle supports pagination so you can page through your result set. Anyone know if Sybase IQ (v12.6 or v12.7) supports something similar?

The end goal is to page through the entire result set (1000 records) but in 100 row pages at a time.

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

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

发布评论

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

评论(2

人│生佛魔见 2024-07-31 23:59:30

我不知道sybase。 但也许你可以做这样的事情,

myproc(@count int, @lastid int)

select top @count *
from MyTabel 
where id > @lastid 
order by id

第一个调用

exec myproc(100, 0)

会给你类似

3 appels
4 banana
..
..
..
346 potatto

下一个调用的

东西exec myproc myproc(100,346)

I don't know sybase. But maybe you could do something like this

myproc(@count int, @lastid int)

select top @count *
from MyTabel 
where id > @lastid 
order by id

first call

exec myproc(100, 0)

gives you something like

3 appels
4 banana
..
..
..
346 potatto

next call

exec myproc myproc(100,346)

回眸一笑 2024-07-31 23:59:30

Sybase IQ 和 Sybase SQL Anywhere 共享相同的查询执行引擎和(大部分)SQL 语法,因此您通常可以使用 SQL Anywhere 语法。 试试这个:

select top (endIndex-startIndex) start at startIndex from <query>

我不确定您是否可以在 top 子句中使用表达式,因此您可能必须创建一个字符串并使用立即执行

请参见 http://dcx.sybase.com/index。 html#1201/en/dbreference/select-statement.html

Sybase IQ and Sybase SQL Anywhere share the same query execution engine and (mostly) SQL syntax, so you can generally use SQL Anywhere syntax. Try this:

select top (endIndex-startIndex) start at startIndex from <query>

I'm not sure if you can use an expression in the top clause, so you may have to create a string and use execute immediate.

See http://dcx.sybase.com/index.html#1201/en/dbreference/select-statement.html

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