Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Oracle => symbol used for

DECLARE
price_to_update NUMBER(6,2) := 20;

updated_price NUMBER(6,2) := 0;

BEGIN


dbms_output.put_line('price before ' || price_to_update);

dbms_output.put_line('updated_price before ' || updated_price);

changePrice (old_price => price_to_update, new_price => updated_price);

dbms_output.put_line('price_to_update after update ' || price_to_update);

dbms_output.put_line('updated_price after update ' || updated_price);

END;

/

in this example user is using => symbol i am unable to figure out for what purpose user using it ... KIndly Help me out ... thanks

like image 440
Adnan Avatar asked Dec 22 '22 10:12

Adnan


2 Answers

It's the named notation for subprogram parameters (vs. positional notation). This syntax allows to:

  1. Swap parameters.
  2. Omit optional parameters.

Example:

PROCEDURE FOO(A VARCHAR2:=NULL, B VARCHAR2:=NULL, C VARCHAR2:=NULL)

... can be called as:

FOO(C=>'FOO', A=>'BAR');
like image 136
Álvaro González Avatar answered Jan 21 '23 20:01

Álvaro González


It is called "named parameter notation". If you have this procedure:

procedure changeprice (old_price number, new_price number);

then you can call it with positional notation:

changeprice (price_to_update, updated_price);

or you can call it with positional notation:

changeprice (old_price => price_to_update, new_price => updated_price);

See documentation for more details.

like image 34
Tony Andrews Avatar answered Jan 21 '23 19:01

Tony Andrews