ACS Documentation : ACS Engineering Standards : PL/SQL Standards
create or replace procedure|function <proc_or_func_name> (
<param_1> in|out|inout <datatype>,
<param_2> in|out|inout <datatype>,
...
<param_n> in|out|inout <datatype>
)
[return <datatype>]
is
<local_var_1> <datatype>
<local_var_2> <datatype>
...
<local_var_n> <datatype>
begin
...
end <proc_or_func_name>;
/
show errors
create or replace procedure|function
<proc_or_func_name>. It makes reloading packages much
easier and painless to someone who is upgrading or fixing a bug.
end statements, i.e., the
end statement for a package should be end
<package_name>;, not just end;; same
goes for procedures, functions, package bodies, and triggers.
acs_user.create(first_names => 'Jane', last_name => 'Doe', etc.)
instead of
acs_user.create(first_names_in => 'Jane', last_name_in => 'Doe', etc.)
To achieve this we must fully qualify arguements passed into
procedures or functions when using them inside a SQL
statement. This will get rid of any ambiguities in your code,
i.e. it will tell the parser when you want the value of the column
and when you want the value from the local variable. Here is an
example:
create or replace package body mypackage
.
.
procedure myproc(party_id in parties.party_id%TYPE) is begin
.
.
delete
from parties
where party_id = myproc.party_id;
.
.
end myproc;
.
.
end mypackage;
/
show errors
new functions (e.g., acs_object.new,
party.new, etc.) should optionally accept an ID:
create or replace package acs_object
as
function new (
object_id in acs_objects.object_id%TYPE default null,
object_type in acs_objects.object_type%TYPE default 'acs_object',
creation_date in acs_objects.creation_date%TYPE default sysdate,
creation_user in acs_objects.creation_user%TYPE default null,
creation_ip in acs_objects.creation_ip%TYPE default null,
context_id in acs_objects.context_id%TYPE default null
) return acs_objects.object_id%TYPE;
takes the optional argument object_id. Do this to
allow people to use the same API call when they are doing double
click protection, that is, tehy have already gotten an
object_id and now they want to create the object with
that object_id.
| richardl@arsdigita.com, and yon@arsdigita.com | Last modified: pl-sql.html,v 1.1 2001/01/21 01:49:08 bquinn Exp |