Arav
Arav

Reputation: 5247

Meaning of PLSQL symbol "=>"

What does the => symbol mean in PL/SQL? e.g.

GetAttrNumber(toitemtype => toitemtype,
              toitemkey => toitemkey,
              toactid => toactid)

Upvotes: 23

Views: 37456

Answers (2)

Peter Å
Peter Å

Reputation: 1319

The keyword/value notation can be very useful if you have a long list of parameters and only need to specify subset of them. Especially if you want to skip some of the parameters in the middle of the list of parameters (this requires the skipped parameters to use DEFAULT values). As an example if you have a procedure like this:

PROCEDURE my_proc(
    p_param1  NUMBER DEFAULT 1
  , p_param2  NUMBER DEFAULT 2
  , p_param3  NUMBER DEFAULT 3
  , p_param4  NUMBER DEFAULT 4
  , p_param5  NUMBER DEFAULT 5 
);

Now you can call my_proc() only with only first and last parameter,

my_proc(p_param1 => value1, p_param5 => value2);

Upvotes: 15

DCookie
DCookie

Reputation: 43553

That is the keyword/value notation for passing parameters to a PL/SQL procedure or function.

The left side is the name of the parameter, the right is the value being passed.

It's useful when you don't want to keep to a specific ordering of parameters, or for self-documenting code.

Upvotes: 31

Related Questions