![]() | CYQ.Data componentsCYQ.Data support multi-database application [Txt,Xml,Access, MSSQL, Oracle,SQLite,MySql], help easily and quickly to develop your project |
CYQ.Data 数据框架 Oracle 分页存储过程
Principles |
|
|
| #TopicOwner |
下面是CYQ.Data 数据框架在 Oracle 的 分页存储过程 的代码: 请分开两次执行,先创建Package,再创建存储过程。 create or replace package MyPackage as
type MyCursor is ref cursor; procedure SelectBase(pageIndex int,pageSize int,tableName varchar2,whereStr varchar2, resultCount out int, resultCursor out MyCursor); end MyPackage; --先执行上面的,再执行下面的
create or replace package Body MyPackage is procedure SelectBase(pageIndex int,pageSize int,tableName varchar2,whereStr varchar2, resultCount out int, resultCursor out MyCursor) is --定义变量 newtableName varchar2(4000); rowStart int; rowEnd int; mySql varchar2(8000); whereOnly varchar2(8000); OrderOnly varchar2(400); begin newtableName:=tableName; mySql:='select count(*) from '||tableName; if whereStr is not null and length(whereStr)>0 then rowStart:=instr(whereStr,'order by'); if rowStart>0 then whereOnly:=substr(whereStr, 1,rowStart-1); --取得条件 OrderOnly:=substr(whereStr,rowStart, length(whereStr)-rowStart+1); --取得排序方式(order by 字段 方式) else whereOnly:=whereStr; OrderOnly:=''; end if; whereOnly:=' where '|| whereOnly; mySql:=mySql||whereOnly; end if; execute immediate mySql into resultCount; -- dbms_output.put_line('查询总条数SQL=>'||whereStr||'--'||mySql||resultCount); --执行查询,查询总条数 --不分页查所有 if pageIndex=0 and pageSize=0 then mySql:='select * from '||tableName||whereOnly||OrderOnly; else --计算起始和结束索引 rowStart:=(pageIndex-1)*pageSize+1; rowEnd:=rowStart+pageSize-1; mySql:='select * from (select t.*,RowNum as rn from (select * from '||newtableName||whereOnly||OrderOnly||') t) where rn between '||rowStart||' and '||rowEnd; end if; open ResultCursor for mySql; --dbms_output.put_line('SQL=>'||mySql); end SelectBase; end MyPackage; ![]() |
游客[注册][182.151.214.*]2011/7/31 16:08:02 | #2 | |
![]() | 一些简单的应用还行, 如果我要关联多张表就不行了。 reply: 将多表查询语句加括号成视图就可以了。 |
游客[注册][60.30.33.*]2011/7/26 10:13:09 | #1 | |
![]() | C#中如何调用呢? reply: 和传统的存储过程调用一样!你可以搜索一下!或者下载CYQ.Data V3.0的源码看! |
Post Comment
Bulletin
Article Search
Categories
- Platform for dynamic (20)
- Feedback (9)
- Guide (33)
- Principles (19)
- Project-Case (8)
- Business & Buy (2)
- Technology exchange (45)
New Article
- CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL]
- CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]
- CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value]
- CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select]
- CYQ.Data Components Getting Started Guide [Part 1]
New Comment
- When some one searches for his necessary thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here.
- This is my first time pay a quick visit at here and i am in fact happy to read everthing at alone place.
- I truly appreciate this blog article.Really thank you! Cool.
- please pay a visit to the web sites we follow, like this one particular, as it represents our picks in the web
- Really enjoyed this post.Really thank you!
- Really enjoyed this article.Really looking forward to read more. Great.
- poker bonuses What are the norms of copyright of web content? How as it different from Patent?
- Wow! Thank you! I permanently needed to write on my blog something like that. Can I implement a fragment of your post to my site?
- This website was how do I say it? Relevant!! Finally I ave found something that helped me. Cheers!
- I was reading through some of your content on this internet site and I believe this web site is very informative ! Continue posting.