Oracle过程
procedure Query1(p_condition varchar2,
p_start_pos number,
p_end_pos number,
p_cursor OUT SYS_REFCURSOR) IS
v_sql varchar2(10000);
v_strsql varchar2(10000);
v_order varchar2(4000);
BEGIN
v_strsql := 'select a.INSTANCE_ID,';
v_order := ' order by a.LASTUPDATETIME DESC';
v_sql := v_strsql || v_order;
IF p_condition IS NOT NULL THEN
v_sql := v_strsql || p_condition || v_order;
END IF;
--分页p_start_pos
IF p_start_pos IS NOT NULL AND p_start_pos > 0 THEN
v_sql := 'select rownum rn, temp.* from(' || v_sql || ') temp';
--
v_sql := 'select * from (' || v_sql || ') t
where t.rn >=' || p_start_pos || '
and t.rn<=' || p_end_pos;
END IF;
begin
open p_cursor for v_sql;
exception
when others then
close p_cursor;
end;
END;
<parameterMap id="Query1" class="Hashtable">
<parameter property="p_condition" column="P_CONDITION"/>
<parameter property="p_start_pos" column="P_START_POS"/>
<parameter property="p_end_pos" column="P_END_POS"/>
<parameter property="p_cursor" column="P_CURSOR" dbType="Cursor" direction="Output"/>
</parameterMap>
------解决方案--------------------------------------------------------
v_strsql := 'select a.INSTANCE_ID,';
v_order := ' order by a.LASTUPDATETIME DESC';
v_sql := v_strsql
------解决方案--------------------------------------------------------
v_order;
IF p_condition IS NOT NULL THEN
v_sql := v_strsql