把sqlserver 存储过程转换为
oracle存储过程set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_Pg_Paging]
@Tables varchar(1000), --表名,多红表是请使用 tA a inner join tB b On a.AID = b.AID
@PK varchar(100), --主键,可以带表头 a.AID
@Sort varchar(200) = '', --排序字段
@PageNumber int = 1, --开始页码
@PageSize int = 10, --页大小
@Fields varchar(1000) = '*',--读取字段
@Filter varchar(1000) = NULL,--Where条件
@Group varchar(1000) = NULL, --分组
@isCount bit = 0 --1 --是否获得总记录数
AS
--
--select * from GL_NEWS order by GN_UPDATE_DATE DESC
--exec Pg_Paging @Tables = 'tb_NewsInfo', @PK = 'News_ID', @Sort = 'News_ID DESC', @PageNumber = 2, @PageSize = 15,@Fields = '*', @Group = '', @isCount = 0
DECLARE @strFilter varchar(2000)
declare @sql varchar(8000)
IF @Filter IS NOT NULL AND @Filter != ''
BEGIN
SET @strFilter = ' WHERE ' + @Filter + ' '
END
ELSE
BEGIN
SET @strFilter = ''
END
if @isCount = 1 --只获得记录条数
begin
set @sql = 'SELECT Count(*) FROM ' + @Tables + @strFilter
end
else
begin
if @Sort = ''
set @Sort = @PK + ' DESC '
IF @PageNumber < 1
SET @PageNumber = 1
if @PageNumber = 1 --第一页提高性能
begin
set @sql = 'select top ' + str(@PageSize) +' '+@Fields+ ' from ' + @Tables + ' ' + @strFilter + ' ORDER BY '+ @Sort
end
else
begin
/**//**//**//*Execute dynamic query*/
DECLARE @START_ID varchar(50)
DECLARE @END_ID varchar(50)
SET @START_ID = convert(varchar(50),(@PageNumber - 1) * @PageSize + 1)
SET @END_ID = convert(varchar(50),@PageNumber * @PageSize)
set @sql = ' SELECT '+@Fields+ '
FROM (SELECT ROW_NUMBER() OVER(ORDER BY '+@Sort+') AS rownum,
'+@Fields+ '
FROM '+@Tables+') AS D
WHERE rownum BETWEEN '+@START_ID+' AND ' +@END_ID +' ORDER BY '+@Sort
END
END
--print @sql
EXEC(@sql)
void bindData()
{
int recCount=0;
dlProducts.DataSource = ProductBLL.GetAllProducts("tb_product", "productid", "productid", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, "*", "", "",out recCount);
dlProducts.DataBind();
AspNetPager1.RecordCount=recCount;
}
------解决方案--------------------1. 不要@符号
2. 句末加;号
3. 不要declare
4. =号改:=
5. @S=@S+TimeCardTime 要用游标循环 for 变量 in (...) loop ... end loop
6.没有关bit类型. 用char(1)代替吧.
帮你改了一些, 太多了. 你自己改吧.
------解决方案--------------------学习!