通过pl/sql实现分页
我正在尝试找出一种通过存储过程调用来实现分页的方法。例如,我有一个包含 100 行的“图像”表。一个网站将请求“第一个”12 个,然后当用户“转到下一页”时,该网站将请求下一个 12 个。
我将在参数中获取 2(p_Offset 和 p_RecordCount),我需要返回一个引用。 p_Offset 将告诉我从哪里开始获取数据,p_RecordCount 将告诉我有多少(p_Offset = 13,p_RecordCount = 12 将告诉我从第 13 行开始返回 12 行。
我们正在使用 Oracle 10g,我开始查看记录类型,但我有一种感觉,我让这变得更加困难,任何帮助将不胜感激。
I'm trying to figure out a way to implement paging via stored procedure calls. For example, I have an 'Images' table that has say 100 rows. A website is going to make a request for the 'first' 12 then when the user 'goes to the next page' the site will make a request for the next 12.
I'll be getting 2 in params (p_Offset and p_RecordCount) and I'll need to return a refcursor. The p_Offset will tell me where to start getting data from and p_RecordCount will tell me how many (p_Offset = 13, p_RecordCount = 12 will tell me to return 12 rows starting from the 13th row.
We're using Oracle 10g and I started looking at RECORD types but I have a feeling I'm making this more difficult then it needs to be. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经找到了解决方案,但我仍然很好奇是否有其他/更好的方法来处理它。这是我想出的:
I think I've got a solution but I'm still curious if there are other/better ways of handling it. Here's what I came up with: