Oracle 10g
Hi Gurus
I was reading one of the question from PL/SQL challenge website https://plsqlchallenge.oracle.com/pls/apex/f?p=10000:23:114157934581224::NO::: but unable to get the exact idea.
I appreciate if someone help me out to understand code.
Sample data
set serveroutput on
/
drop table plch_stuff;
/
CREATE TABLE plch_stuff (
id INTEGER PRIMARY KEY,
nm VARCHAR2 (5) UNIQUE)
/
create or replace procedure plch_insert (
insert_row_in IN BOOLEAN DEFAULT TRUE)
IS
begin
IF insert_row_in
THEN
INSERT INTO plch_stuff VALUES (1, 'Hat');
END IF;
END;
/
begin
plch_insert;
UPDATE plch_stuff SET nm = 'Hat';
dbms_output.put_line('Last Count='||SQL%ROWCOUNT);
END;
Result
Last Count=1
But as per my understanding , result =Last Count=2 because one sql%rowcount for insert and then one for update. Please guide. Thanks
Regards
Matt