我想根据以下link进行自定义分页:
但我的存储过程在informix中:
所以我搜索等效的row_number()
我发现这个solution
但是当我在我的程序中使用它时,我收到以下错误:
SQL错误-944在此上下文中不能使用“first”,“limit”,“skip”!
如何使用informix规则重写上一个链接中的存储过程?
我的程序有多个联合会是这样的:
create procedure get_inbox_page(p_emp_num smallint, p_task_code smallint, p_main_code smallint default 0, p_year smallint default 0,p_page int)
returning varchar(60) as v_page_view, varchar(60) as v_task_name, smallint as v_task_code, varchar(60) as v_sp_name, varchar(60) as v_db_name, varchar(60) as v_column_key, smallint as v_trans_serial,
DATETIME YEAR TO FRACTION(3) as v_trans_date, varchar(60) as v_trans_desc , varchar(60) as v_emp_name, varchar(60) as v_values_key, smallint as v_old_state_serial,
smallint as v_new_state_serial, smallint as v_main_code, smallint as v_year, varchar(60) as v_page_new, smallint as v_task_type, smallint as v_task_status,smallint as v_mail_maincode,smallint as v_mail_year,smallint as v_mail_number,smallint as v_trans_year , smallint as candidate_flag ;
Select ......
UNION
Select ......
UNION
Select ......
答案 0 :(得分:2)
您无法使用FIRST
,SKIP
等,因为SELECT
集合中的每个UNION
语句都是自包含的。
也许您可以尝试创建一个封装VIEW
逻辑的SELECT ... UNION ... SELECT
,然后将FIRST
/ SKIP
逻辑应用于此。
答案 1 :(得分:0)
试试这个
;
WITH tempPagedRecord
AS ( SELECT Column1 ,
Column2 ,
Column3
FROM TableName AS e--Your query with union
UNION ALL
SELECT Column1 ,
Column2 ,
Column3
FROM TableName AS e--Your query with union
)
SELECT * ,
ROW_NUMBER() OVER ( ORDER BY Column1 ASC ) AS RowNumber--RowNumber over some column
FROM tempPagedRecord
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1