Skip to main content
← PL/SQL Topics

Packages & Modularity

Explain default parameter values and named vs positional notation

Default Parameters and Named Notation

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

Parameters can have DEFAULT values; callers may pass arguments positionally, by name (=>), or a mix.

How it works

A formal parameter with DEFAULT expr (or := expr) may be omitted by the caller. To skip a middle optional parameter you must switch to named notation, arg_name => value, which also makes long calls self-documenting. Mixed notation is allowed but every positional argument must come before the first named one. Defaults are evaluated at call time in the caller's context.

How it works
CREATE OR REPLACE PROCEDURE log_msg (
  p_text    VARCHAR2,
  p_level   VARCHAR2 := 'INFO',
  p_module  VARCHAR2 := 'GENERAL'
) AS
BEGIN
  INSERT INTO app_log(log_text, log_level, module, logged_on)
  VALUES (p_text, p_level, p_module, SYSTIMESTAMP);
END;
/
BEGIN
  log_msg('started');                              -- both defaults
  log_msg('cache miss', p_module => 'PRICING');    -- skip p_level by name
END;
/

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI