Optional Parameters in Teradata SPL

Database
Enthusiast

Optional Parameters in Teradata SPL

Is there a way for us to define optional parameters in a Stored Procedure synonymous to that of an Oracle Stored Procedure?

  • Optional Parameters

Accepted Solutions
Junior Contributor

Re: Optional Parameters in Teradata SPL

There's a kind of workaround:

 

Create a wrapper Macro to call the Procedure:

replace macro mymac (param1 int, param2 int, param3 int default 0) as
 (
   call mySP(:param1, :param2, :param3);
 );

Now you can execute the macro using named parameters:

exec mymac(param1 = 3);

 param2 will be NULL and param3 defaults to 0

 

1 ACCEPTED SOLUTION
2 REPLIES
Teradata Employee

Re: Optional Parameters in Teradata SPL

No, Teradata Stored Procedures do not offer optional or default parameters.

 

All Teradata Database documentation is available at www.info.teradata.com

 

The syntax for creating Teradata Stored Procedures appears in the PDF "Teradata Database Reference - SQL Data Definition Language - Syntax and Examples"

 

Junior Contributor

Re: Optional Parameters in Teradata SPL

There's a kind of workaround:

 

Create a wrapper Macro to call the Procedure:

replace macro mymac (param1 int, param2 int, param3 int default 0) as
 (
   call mySP(:param1, :param2, :param3);
 );

Now you can execute the macro using named parameters:

exec mymac(param1 = 3);

 param2 will be NULL and param3 defaults to 0