日期:2014-05-17 浏览次数:21405 次
create or replace procedure SP_GetXmInc(pTableName in nvarchar2,
pFieldName in nvarchar2,
pCondition in nvarchar2,
cur_OUT OUT SYS_REFCURSOR) is
v_sql VARCHAR2(8000);
begin
savepoint sp_begintran;
v_sql := 'lock table ' || pTableName || ' in exclusive mode';
execute immediate v_sql;
v_sql := 'update ' || pTableName || ' set ' || pFieldName || ' = ' ||
pFieldName || ' + 1';
if (pCondition is not null) then
v_sql := v_sql || ' where ' || pCondition;
end if;
execute immediate v_sql;
v_sql := 'select ' || pFieldName || ' from ' || pTableName;
if (pCondition is not null) then
v_sql := v_sql || ' where ' || pCondition;
end if;
open cur_OUT for v_sql;
commit;
exception
when others then
rollback to sp_begintran;
end SP_GetXmInc;