Q

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

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

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

Dig deeper on Using Oracle PL-SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close