按照你的规则,提取出全部数据,然后:
在asp.net里面: private void DataGrid2_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
SaveData mynews = new SaveData();
String Strsql = "select * from tab_new where classid='5' order by id desc";
DataGrid2.DataSource=mynews.ShowNews(Strsql);
DataGrid2.CurrentPageIndex=e.NewPageIndex;
Page.DataBind();
}
你自己不用去关心它如何去取下面的n条数据。
在asp.net里面: private void DataGrid2_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
SaveData mynews = new SaveData();
String Strsql = "select * from tab_new where classid='5' order by id desc";
DataGrid2.DataSource=mynews.ShowNews(Strsql);
DataGrid2.CurrentPageIndex=e.NewPageIndex;
Page.DataBind();
}
你自己不用去关心它如何去取下面的n条数据。
如:可以前端用一个下拉框选择以那个字段进行排序
"select * from table_name order by "+变量;
select * from (select rownum rm,a.* from table_name a order by name) where rm<=n and rm>=m;
查询20万条记录的分页显示(10秒),和不用order by查询()0.89秒,时间相差5--6倍。该怎么办呢?速度太慢了??????????????????????????????????????????????
必须得用order by,怎样提高速度呢???????????????????????????????????????????????????
select rownum r,...... from tbname)
where r between (页号-1)*页显示数
and 页号*页显示数;你在jsp中调用过程就可以了,这样做既灵活又高效。没问题的。
谢谢
select * from (select rownum id,a.* from people a order by name) where id between 变量1 and 变量2; 根据我的问题能否给我写一个oracle的过程,我不太会写oracle过程。我需要传两个参数(变量1、变量2)
能否给个oralce过程具体的代码,过程执行后返回一个查询的结果集。
请您帮帮我吧!!!!!!!!!!
等等
as
type ref_cursor is ref cursor;
function get_page_by_search(
v_sel_condition in varchar2, n_page_id in number,
n_list_num in number -- 每页显示的记录条数
) return ref_cursor;
end;create or replace package body test
as
function get_page_by_search(
v_sel_condition in varchar2, n_page_id in number,
n_list_num in number -- 每页显示的记录条数
) return ref_cursor;
is
rc ref_cursor;
begin
open rc for select * from (select rownum id,a.* from people a order by name) where id between 变量1 and 变量2;
return rc;
exception
when others then
if rc%isopen then
close rc;
end if;
end;
您好,为什么我作的包创建时出现如下错误提示“警告: 创建的包带有编译错误。”
代码如下:
create or replace package test
as
type ref_cursor is ref cursor;
function get_page_by_search(v_sel_condition in varchar2,v_curpage in number,v_list_num in number) return ref_cursor;
end;create or replace package body test
as
function get_page_by_search(v_sel_condition in varchar2,v-curpage in number,v_list_num in number) return ref_cursor;
is
rc ref_cursor;
begin
open rc for select * from (select rownum id,a.* from people a order by name) where id between (v_curpage-1)*v_list_num and v_curpage*v_list_num;
return rc;
exception
when others then
if rc% is open then
close rc;
end if;
end;
as
function get_page_by_search(v_sel_condition in varchar2,
v_curpage in number,
v_list_num in number) return ref_cursor
is
rc ref_cursor;
begin
open rc for select * from (select rownum id,a.* from people a order by name) where id between (v_curpage-1)*v_list_num and v_curpage*v_list_num;
return rc;
exception
when others then
if rc %isopen then
close rc;
end if;
end get_page_by_search;
end test;
create or replace package test
as
type ref_cursor is ref cursor;
function get_page_by_search(v_sel_condition in varchar2,v_curpage in number,v_list_num in number) return ref_cursor;
end;create or replace package body test
as
function get_page_by_search(v_sel_condition in varchar2,
v_curpage in number,
v_list_num in number) return ref_cursor
is
rc ref_cursor;
begin
open rc for select * from (select rownum id,a.* from people a order by name) where id between (v_curpage-1)*v_list_num and v_curpage*v_list_num;
return rc;
exception
when others then
if rc %isopen then
close rc;
end if;
end get_page_by_search;
end test;
您能不能试一下?
我试了还不行,提示同上?
真的很麻烦您了!
2 NAME VARCHAR2(30) not null,
3 ADDRESS VARCHAR2(50) not null,
4 TEL VARCHAR2(30) not null,
5 FAX VARCHAR2(30) not null,
6 EMAIL VARCHAR2(50) not null,
7 constraint PK_PEOPLE primary key (NAME)
8 );Table createdSQL>
SQL> create or replace package test
2 as
3 type ref_cursor is ref cursor;
4 function get_page_by_search(v_sel_condition in varchar2,v_curpage in number,v_list_num in number) return ref_cursor;
5 end;
6 /Package createdSQL>
SQL> create or replace package body test
2 as
3 function get_page_by_search(v_sel_condition in varchar2,
4 v_curpage in number,
5 v_list_num in number) return ref_cursor
6 is
7 rc ref_cursor;
8 begin
9 open rc for select * from (select rownum id,a.* from people a order by name) where id between (v_curpage-1)*v_list_num and v_curpage*v_list_num;
10 return rc;
11 exception
12 when others then
13 if rc %isopen then
14 close rc;
15 end if;
16 end get_page_by_search;
17 end test;
18 /Package body created没有问题啊!
特别感谢张波!
程序包和程序主体已建立!
在jsp中如何调用程序包,而后使用使用程序包返回的值呢?
又要麻烦您了
对不起
我的信箱:[email protected]
真的十分感谢!!
cstmt = conn.prepareCall(query);
cstmt.registerOutParameter(1,OracleTypes.CURSOR);
cstmt.setInt(2,...);
.........
cstmt.execute();
rset = (ResultSet)cstmt.getObject(1);
if(rset.next()){
...... //循环取值
}
.........
您好,已经用jsp调程序包实现,但还是比较慢,可否再改造一下,有了order by name(主键),太慢了
是否可以在优化!!!
谢谢!
您好!
谢谢您的帮助!name是主键如何在其上建索引?
我也试图在name上建索引,但失败了!
等您回音!
您好:谢谢您的关注!
如何分区,(或按照某范围保存到不同的表里面)
每个分区保存2-5万条? 我没用过,能否具体说一下,一旦可以马上揭贴!
我的信箱:[email protected]
( invoice_no NUMBER,
sale_year INT NOT NULL,
sale_month INT NOT NULL,
sale_day INT NOT NULL )
PARTITION BY RANGE (invoice_no)
( PARTITION sales_q1 VALUES LESS THAN (20000)
TABLESPACE tsa,
PARTITION sales_q2 VALUES LESS THAN (40000)
TABLESPACE tsb,
PARTITION sales_q3 VALUES LESS THAN (60000)
TABLESPACE tsc,
PARTITION sales_q4 VALUES LESS THAN (80000)
TABLESPACE tsd
...);
这种情况下我怎样知道总共的结果数呢?我想在页面上放一个“共 页”;请教!
(我用的是java)
您好,如何建立用户scott的表空间tsa、tsb、tsc、、、
分区和表空间有什么区别??
谢谢!
DATAFILE Datafile_Options Storage_Options ;Datafile_Options: 'filespec' [AUTOEXTEND OFF]
'filespec' [AUTOEXTEND ON [NEXT int K | M] [MAXSIZE int K | M]]
The Autoextend Maxsize clause will default to UNLIMITED if no value is specified. Storage_Options: DEFAULT STORAGE storage_clause
MINIMUM EXTENT int {K|M}
LOGGING | NOLOGGING
ONLINE | OFFLINE
PERMANENT | TEMPORARY
EXTENT MANAGEMENT {DICTIONARY |
LOCAL {AUTOALLOCATE | UNIFORM [SIZE int K | M]} }
可以把一个表放在一个表空间里,也可以放在多个表空间里
create index indexname on tbname(name) local;