Skip to content

Instantly share code, notes, and snippets.

@xtender
Created January 22, 2015 17:40
Show Gist options
  • Select an option

  • Save xtender/7d210be295cfe5bf3c5d to your computer and use it in GitHub Desktop.

Select an option

Save xtender/7d210be295cfe5bf3c5d to your computer and use it in GitHub Desktop.
PL/SQL: NVL vs Coalesce - 2
alter session set plsql_optimize_level=0;
declare
i integer;
a number :=1;
b number :=1;
l integer:=dbms_utility.get_time();
procedure print(v in varchar2) is
begin
dbms_output.put_line(to_char((dbms_utility.get_time-l)/100,'0999.99')||' '||v);
l:=dbms_utility.get_time();
end;
begin
print('Start');
for i in 1..1e7 loop
a:=nvl(b,i);
end loop;
print('NVL');
for i in 1..1e7 loop
a:=coalesce(b,i);
end loop;
print('Coalesce');
end;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment