首页 新闻 会员 周边 捐助

sqlserver存储过程转换成oracle存储过程

0
悬赏园豆:50 [已关闭问题] 关闭于 2011-11-08 14:15

USE [USInfo]
GO
/****** 对象:  StoredProcedure [dbo].[ent_Pages]    脚本日期: 10/26/2011 15:33:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

                
CREATE PROCEDURE [dbo].[ent_Pages]                    
    (    
    @Primaryid varchar(100),                
    @TableName varchar(1000),                
    @FieldList varchar(2000),                           
    @StrWhere varchar(2000),                   
    @OrderField varchar(1000),                 
    @PageIndex int,                
    @PageSize int,                
    @PageCount int output,                
    @RecordCount int output                
    )                     
AS                     
                  
SET NOCOUNT ON                   
                
DECLARE @intRootRecordCount int                  
DECLARE @SqlQuery nvarchar(4000)                   
                   
SET @PageCount=0              
SET @SqlQuery= 'SET NOCOUNT ON;SELECT @SPintRootRecordCount=Count(*) FROM '+@TableName+' WHERE '+@StrWhere                    
EXECUTE sp_executesql @SqlQuery,N'@SPintRootRecordCount int OUTPUT',@SPintRootRecordCount=@intRootRecordCount OUTPUT                  
SELECT @RecordCount = @intRootRecordCount                  
IF @RecordCount=0                  
    return                  
ELSE                  
  BEGIN                  
   SELECT @PageCount=(@RecordCount+@PageSize-1)/@PageSize                           
   IF @PageIndex=1    
          IF @StrWhere!=''    
        SELECT @SqlQuery='SELECT TOP '+CAST(@PageSize AS VARCHAR(20))+' '+@FieldList+' FROM ' +@TableName+' WHERE '+@StrWhere +' ORDER BY '+@OrderField        
          ELSE    
              SELECT @SqlQuery='SELECT TOP '+CAST(@PageSize AS VARCHAR(20))+' '+@FieldList+' FROM ' +@TableName+' ORDER BY '+@OrderField        
   ELSE         
    SET @SqlQuery='SELECT '+@FieldList+' FROM '+@TableName+' WHERE '+@StrWhere +' AND a.'+@Primaryid+' in(SELECT '+@Primaryid+' FROM (SELECT row_number() over(ORDER BY '+@OrderField+') as rownum,a.'+@Primaryid+' FROM '+@TableName+' WHERE '+@StrWhere +') as temptbl                    
    WHERE rownum BETWEEN ('+cast(@PageIndex as varchar)+'-1)*'+cast(@PageSize as varchar)+'+1 and '+cast(@PageIndex as varchar)+'*'+cast(@PageSize as varchar) + ') ORDER BY '+@OrderField             
   END     
      SET NOCOUNT ON              
      EXECUTE(@SqlQuery)                    
      SET NOCOUNT OFF

 

 

望ORACLE高手帮忙改写

深思学者的主页 深思学者 | 初学一级 | 园豆:200
提问于:2011-10-26 16:56
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册