Forum OpenACS Q&A: Re: Difference between PL/SQL Procedure and PL/SQL Function

A PL/SQL function returns a value, a procedure does not. Oracle is picky about this. The following, for example, will cause an error:
SQL> create or replace function unity
return integer
as
begin
   return 1;
end;
/

begin
  unity();
end;
/
show errors

  2    3    4    5    6    7
Function created.

SQL> SQL>   2    3    4    unity();
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00221: 'UNITY' is not a procedure or is undefined
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored
Because unity is a function, we must return its result into a variable...
SQL> declare
  v_result integer;
begin
  v_result := unity();
end;
/
show errors

  2    3    4    5    6
PL/SQL procedure successfully completed.
I think Postgres is not as picky.