The structure of procedures
244
Declaring parameters for procedures
Procedure parameters, or arguments, are specified as a list in the CREATE
PROCEDURE statement. Parameter names must conform to the rules for other
database identifiers such as column names. They must be a valid data types
(see “SQL Data Types” in Adaptive Server IQ Reference Manual), and must be
prefixed with one of the keywords IN, OUT or INOUT. These keywords have
the following meanings:
•
IN
The argument is an expression that provides a value to the
procedure.
•
OUT
The argument is a variable that could be given a value by the
procedure.
•
INOUT
The argument is a variable that provides a value to the
procedure, and could be given a new value by the procedure.
Default values can be assigned to procedure parameters in the CREATE
PROCEDURE statement. The default value must be a constant, which may be
NULL. For example, the following procedure uses the NULL default for an IN
parameter to avoid executing a query that would have no meaning:
CREATE PROCEDURE
CustomerProducts( IN customer_id
INTEGER DEFAULT NULL )
RESULT ( product_id INTEGER,
quantity_ordered INTEGER )
BEGIN
IF customer_id IS NULL THEN
RETURN;
ELSE
SELECT product.id,
sum( sales_order_items.quantity )
FROMproduct,
sales_order_items,
sales_order
WHERE sales_order.cust_id = customer_id
AND sales_order.id = sales_order_items.id
AND sales_order_items.prod_id=product.id
GROUP BY product.id;
END IF;
END
The following statement causes the DEFAULT NULL to be assigned, and the
procedure returns instead of executing the query.
CALL CustomerProducts();
Summary of Contents for Adaptive Server IQ 12.4.2
Page 1: ...Administration and Performance Guide Adaptive Server IQ 12 4 2 ...
Page 16: ...xvi ...
Page 20: ...Related documents xx ...
Page 40: ...Compatibility with earlier versions 20 ...
Page 118: ...Troubleshooting startup shutdown and connections 98 ...
Page 248: ...Importing data by replication 228 ...
Page 306: ...Integrity rules in the system tables 286 ...
Page 334: ...Cursors in transactions 314 ...
Page 396: ...Users and permissions in the system tables 376 ...
Page 438: ...Determining your data backup and recovery strategy 418 ...
Page 484: ...Network performance 464 ...
Page 500: ...System utilities to monitor CPU use 480 ...
Page 514: ...Characteristics of Open Client and jConnect connections 494 ...
Page 536: ...Index 516 ...