Ask the Expert

What is "=>" used for in PL/SQL?

What is "=>" used for in PL/SQL?

    Requires Free Membership to View

It is used to identify a value for a parameter name. Here's an example:

CREATE PROCEDURE my_proc (parm1 IN varchar2, parm2 IN date DEFAULT sysdate, parm3 IN number)
AS   . . . code for this procedure would go here. . .
Now, when you want to call this procedure in a PL/SQL code block, you'd call it as follows:
begin
   my_proc('XYZ', to_date('12/12/2002','mm/dd/yyyy'), 123) ;
end;
/
But, what if you wanted to call the procedure and not pass the second parameter (parm2 IN date) and simply allow it to use the default of sysdate which you specified in the procedure parameter definition. This is how you'd do it:
begin
   my_proc(parm1 => 'XYZ', parm3 => 123) ;
end;
/
So... "=>" is used to assign the value indicated to the named parameter. You can use this syntax every time you call the procedure for clarity and to "self-document" your code as well.

For More Information


This was first published in December 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: