在ORACLE的存储过程中如何判断插入或更新语句影响的记录条数
how_to_get_oracle_procedures_dml_update_or_insert_row
具体例子如下:
create or replace procedure pro_test_insert is
--declare
i_count integer;
begin
--insert into scott.dept values (70,'itlife365.com','xiamen');
execute immediate 'update scott.dept set dname=''itlife365.com'' where deptno=''60''';
--update scott.dept set dname='itlife365.com' where deptno='60';
dbms_output.put_line('影响行数:'||to_char(sql%rowcount)); --直接打印改变行数的参数sql%rowcount
commit;
end pro_test_insert;
执行结果
Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
Connected as SYS
SQL> set time on
12:30:52 SQL> set serveroutput on
12:31:00 SQL> exec pro_test_insert;
影响行数:1
PL/SQL procedure successfully completed
12:31:55 SQL>
关于sql%rowcount的用法参考
http://itlife365.com/blog/post/oracle_cursor_sql_found_notfound_rowcount.php
how_to_get_oracle_procedures_dml_update_or_insert_row
具体例子如下:
create or replace procedure pro_test_insert is
--declare
i_count integer;
begin
--insert into scott.dept values (70,'itlife365.com','xiamen');
execute immediate 'update scott.dept set dname=''itlife365.com'' where deptno=''60''';
--update scott.dept set dname='itlife365.com' where deptno='60';
dbms_output.put_line('影响行数:'||to_char(sql%rowcount)); --直接打印改变行数的参数sql%rowcount
commit;
end pro_test_insert;
执行结果
Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
Connected as SYS
SQL> set time on
12:30:52 SQL> set serveroutput on
12:31:00 SQL> exec pro_test_insert;
影响行数:1
PL/SQL procedure successfully completed
12:31:55 SQL>
关于sql%rowcount的用法参考
http://itlife365.com/blog/post/oracle_cursor_sql_found_notfound_rowcount.php