oracle存储过程 转为 sql servler存储过程
CREATEORREPLACEPROCEDUREPAGINATION(pageIndexINNUMBERDEFAULT1,pageSizeINNUMBER,pageSql...
CREATE OR REPLACE
PROCEDURE PAGINATION
(
pageIndex IN NUMBER DEFAULT 1,
pageSize IN NUMBER,
pageSql IN VARCHAR2,
pageTotal OUT NUMBER,
rs OUT Sys_Refcursor,
recordTotal OUT NUMBER
) AS
v_sql VARCHAR2(1000); ---计算总条数
v_count number; ---总条数
v_Plow number; ---闭区间下限
v_Phei number; ---闭区间上限
BEGIN
-----------取分页总数 -----------------------
v_sql := 'select count(*) from (' || pageSql || ')';
execute immediate v_sql into v_count;
pageTotal := ceil(v_count/pageSize);
recordTotal := v_count;
---------------自己加的:判断pageIndex是否超过页面总数 ----------------
IF pageIndex > pageTotal THEN
BEGIN
v_Phei := pageTotal * pageSize ;
END;
ELSE
v_Phei := pageIndex * pageSize ;
END IF;
---------------显示任意页内容 ----------------
--- v_Phei := pageIndex * pageSize ;---
v_Plow := v_Phei - pageSize + 1;
-----v_sql := 'select * from (select rownum rn,t.* from (' || pageSql || ')t) where rn between ' || v_Plow || ' and ' || v_Phei ;-----
v_sql := 'select * from (select rownum rn,t.* from (' || pageSql || ')t) where rn between ' || v_Plow || ' and ' || v_Phei ;
-----------------得到记录集-------------------
open rs for v_sql;
END PAGINATION; 展开
PROCEDURE PAGINATION
(
pageIndex IN NUMBER DEFAULT 1,
pageSize IN NUMBER,
pageSql IN VARCHAR2,
pageTotal OUT NUMBER,
rs OUT Sys_Refcursor,
recordTotal OUT NUMBER
) AS
v_sql VARCHAR2(1000); ---计算总条数
v_count number; ---总条数
v_Plow number; ---闭区间下限
v_Phei number; ---闭区间上限
BEGIN
-----------取分页总数 -----------------------
v_sql := 'select count(*) from (' || pageSql || ')';
execute immediate v_sql into v_count;
pageTotal := ceil(v_count/pageSize);
recordTotal := v_count;
---------------自己加的:判断pageIndex是否超过页面总数 ----------------
IF pageIndex > pageTotal THEN
BEGIN
v_Phei := pageTotal * pageSize ;
END;
ELSE
v_Phei := pageIndex * pageSize ;
END IF;
---------------显示任意页内容 ----------------
--- v_Phei := pageIndex * pageSize ;---
v_Plow := v_Phei - pageSize + 1;
-----v_sql := 'select * from (select rownum rn,t.* from (' || pageSql || ')t) where rn between ' || v_Plow || ' and ' || v_Phei ;-----
v_sql := 'select * from (select rownum rn,t.* from (' || pageSql || ')t) where rn between ' || v_Plow || ' and ' || v_Phei ;
-----------------得到记录集-------------------
open rs for v_sql;
END PAGINATION; 展开
1个回答
展开全部
CREATE OR REPLACE PROCEDURE proc_Inf_Add
(
v_Name in varchar2,
v_Size in number,
v_Tname in varchar2,
v_Text in varchar2,
v_Date in varchar2,
v_ture in blob --oracle中没有image,需要在Inf表中修改这个字段的类型,改为blob即可
)
is
v_Tid number;
begin
select Tid into v_Tid from Type where Tname=v_Tname;
if v_Tid is not null then
insert into Inf(Name,Size,Tid,Text,Date,ture) values(v_Name,v_Size,v_Tid,v_Text,to_date(v_Date, 'yyyy-mm-dd'),v_ture);
end if;
end;
(
v_Name in varchar2,
v_Size in number,
v_Tname in varchar2,
v_Text in varchar2,
v_Date in varchar2,
v_ture in blob --oracle中没有image,需要在Inf表中修改这个字段的类型,改为blob即可
)
is
v_Tid number;
begin
select Tid into v_Tid from Type where Tname=v_Tname;
if v_Tid is not null then
insert into Inf(Name,Size,Tid,Text,Date,ture) values(v_Name,v_Size,v_Tid,v_Text,to_date(v_Date, 'yyyy-mm-dd'),v_ture);
end if;
end;
追问
oracle转sql server,你的答案还是oracle
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
今至电子科技有限公司
2024-08-23 广告
2024-08-23 广告
数据库备份是确保数据安全与业务连续性的关键环节。我们上海今至电子科技有限公司高度重视数据保护,定期执行全面的数据库备份策略。这包括使用先进工具和技术,对关键业务数据进行自动化备份,并存储在安全可靠的外部存储介质或云端。通过定期验证备份的完整...
点击进入详情页
本回答由今至电子科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询