Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

General
description [Table of Contents] Dropping an AS/400 Stored Procedure

Access Service User's Guide DirectConnect for AS/400

[-] Chapter 14 Using AS/400 Stored Procedures
[-] Creating an AS/400 Stored Procedure

Creating an AS/400 Stored Procedure

To create an AS/400 stored procedure, perform the following tasks:

All tables that the AS/400 stored procedure refers to should be qualified with the collection name. If a table is not qualified with the collection name, AS/400 SQL uses the user profile name of the AS/400 job (connection).

The access service library requires a naming convention to distinguish between SQL stored procedures that return a result set, those that do not, and external stored procedures:

Variables and syntax in Stored Procedures

An AS/400 stored procedure can contain variables, so that arguments can be passed to it when it runs. A argument can be used for any data value in the SQL statement but cannot be used for any table or column name.

The syntax for AS/400 stored procedures is as follows:

create procedure 
procname arglist optionlist as sqlstatement

where:

Arguments in the arglist must be in the following format:

@parmname argtype, ...

or

&parmname argtype, ...

where:

The following requirements apply to the use of variables:

It is best to describe the arguments exactly as they appear in the corresponding column. In some cases, this can allow the AS/400 DBMS to use the SQL statement more efficiently.

The optionlist allows a client to specify information about the stored procedure. The client can specify options only when SQL transformation is in Passthrough mode. Sybase mode does not allow options.

A client can specify the following options:

To include options in a create procedure statement, use a format as follows:

verify=req, isolv=ur, owner=userid

Consider the following guidelines for a create procedure statement:

If the name you supply for procname already exists, the create procedure statement fails. Either drop the conflicting procedure or use a different name for the new procedure.

Interaction between AS/400 Stored Procedures and CSPs

This section describes the interaction between AS/400 stored procedures and catalog stored procedures (CSPs). It also contains information about creating an AS/400 stored procedure and CSP tables.

When the create procedure statement executes, the following events occur:


General
description [Table of Contents] Dropping an AS/400 Stored Procedure