informix
Informix Guide to SQL: Syntax
Segments

Argument

Use the Argument segment to pass a specific value to a routine parameter. Use the Argument segment wherever you see a reference to an argument in a syntax diagram.

Syntax

Element Purpose Restrictions Syntax
parameter Name of a routine parameter for which you supply an argument The parameter name must match the parameter name that you specified in a corresponding CREATE FUNCTION or CREATE PROCEDURE statement. Expression,
p.
4-73
singleton_select Embedded query that returns exactly one value of the proper data type and length This can be any SELECT statement as long as it returns only one value. SELECT,
p.
2-634

Usage

A parameter list for a user-defined routine (UDR) is defined in the CREATE PROCEDURE or CREATE FUNCTION statement. If the UDR has a parameter list, you can enter arguments when you execute the UDR. An argument is a specific data element that matches the data type of one of the parameters for the UDR.

When you execute a UDR, you can enter arguments in one of two ways:

If you use a parameter name for one argument, you must use a parameter name for all the arguments.

In the following example, both statements are valid for a user-defined procedure that expects three character arguments, t, d, and n:

Comparing Arguments to the Parameter List

When you create or register a UDR with CREATE PROCEDURE or CREATE FUNCTION, you specify a parameter list with the names and data types of the parameters the UDR expects.

If you attempt to execute a UDR with more arguments than the UDR expects, you receive an error.

If you execute a UDR with fewer arguments than the UDR expects, the arguments are said to be missing. The database server initializes missing arguments to their corresponding default values. This initialization occurs before the first executable statement in the body of the UDR.

If missing arguments do not have default values, the database server initializes the arguments to the value UNDEFINED. However, you cannot use a variable with a value of UNDEFINED within the UDR. If you do, the database server issues an error.

Subset of Expressions Allowed as an Argument

The diagram for Argument refers to this section.

You can use any expression as an argument, except an aggregate expression. If you use a subquery or function call, the subquery or function must return a single value of the appropriate data type and size. For a complete description of syntax and usage, see Expression.


Informix Guide to SQL: Syntax, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved