Hola amigos necesito si alguien me puede ayudar a pasar este procedimiento de sql a postgre..es un procedimiento de paginacion...desde ya se agradece mucho
saludos..
ALTER PROCEDURE [dbo].[DOMO_Paginacion2005]
@PageSize NVARCHAR(MAX)
,@PageNumber NVARCHAR(MAX)
,@campos AS NVARCHAR(MAX)
,@tabla AS NVARCHAR(MAX)
,@orden AS NVARCHAR(MAX)
,@param AS NVARCHAR(MAX)
,@filtro AS NVARCHAR(MAX)
AS --EXEC sp_tableoption 'HumanResources.JobCandidate', 'large value types out of row', 1;
DECLARE @sql AS NVARCHAR(MAX)
SET @PageNumber = @PageNumber - 1
IF @orden = ''
BEGIN
SET @orden = 'id_' + @tabla
END
IF @filtro = ''
BEGIN
SET @filtro = ' 1=1 '
END
ELSE
BEGIN
SET @filtro = REPLACE(@filtro, '"', '''')
END
IF @param = ''
BEGIN
SET @param = '()'
END
ELSE
IF @param = '('')'
SET @param = '('''')'
-- PRINT @filtro
IF @param <> ''
AND @param <> '0'
BEGIN
SET @sql = ' SELECT ' + @campos + ' FROM ( SELECT ' + @campos
+ ', ROW_NUMBER() OVER
(ORDER BY ' + @orden + ') AS RowNumber FROM ' + @tabla + ' WHERE id_'
+ @tabla + ' in ' + @param + ' and ' + @filtro + ') AS '
+ @tabla + '
WHERE RowNumber BETWEEN ' + @PageSize + ' * ' + @PageNumber + ' + 1 AND '
+ @PageSize + ' * (' + @PageNumber + ' + 1)'
END
ELSE
BEGIN
SET @sql = ' SELECT ' + @campos + ' FROM ( SELECT ' + @campos
+ ', ROW_NUMBER() OVER
(ORDER BY ' + @orden + ') AS RowNumber FROM ' + @tabla + ' WHERE ' + @filtro
+ ' ) AS ' + @tabla + '
WHERE RowNumber BETWEEN ' + @PageSize + ' * ' + @PageNumber + ' + 1 AND '
+ @PageSize + ' * (' + @PageNumber + ' + 1)'
END
PRINT ( @sql )
EXECUTE sp_executesql @sql