使用sql%rowcount
來確定有多少行受到更新的影響。
利用有效的PL/SQL函數:
create table tq84_update_test (
country_code number,
col_id varchar2(10)
);
create or replace
function tq84_update_func (dest in varchar2,
col_id in varchar2,
country_code in number
)
return varchar2
as
begin
execute immediate
'update ' || dest || ' set country_code = :v1 ' ||
'where col_id = :v2'
using country_code, col_id;
return sql%rowcount || ' rows updated';
end tq84_update_func;
/
insert into tq84_update_test values (4,'Italy');
exec dbms_output.put_line(tq84_update_func('tq84_update_test', 'foo', 2));
exec dbms_output.put_line(tq84_update_func('tq84_update_test', 'Italy', 9));
select * from tq84_update_test;
什麼與您的查詢的問題,你得到一個錯誤信息?哪一個? – jachguate 2011-02-16 22:59:24
有點深入研究這個問題讓我意識到錯誤是*** RETURNING ***不支持的功能。我只想知道給定的值是否已更新,我不想使用單獨的select語句。有任何想法嗎? – 2011-02-16 23:04:20