Contents Index sa_locks system procedure sa_migrate system procedure

ASA SQL Reference
  System Procedures and Functions
    System and catalog stored procedures

sa_make_object system procedure


Function 

The sa_make_object procedure can be used in a SQL script to ensure that a skeletal instance of an object exists before executing an ALTER statement which provides the actual definition.

Syntax 

sa_make_object (
objtype,
objname,
[, owner [, tabname, ] )

object-type:
'procedure' | 'function' | 'view' | 'trigger'

Permissions 

Resource authority is required to create or modify database objects.

Side effects 

Automatic commit.

See also 

ALTER FUNCTION statement

ALTER PROCEDURE statement

ALTER TRIGGER statement

ALTER VIEW statement

Description 

This procedure is particularly useful in scripts or command files that are run repeatedly to create or modify a database schema. A common problem in such scripts is that the first time they are run, a CREATE statement must be executed, but subsequent times an ALTER statement must be executed. This procedure avoids the necessity of querying the system tables to find out whether the object exists.

To use the procedure, follow it by an ALTER statement that contains the entire object definition.

You can also use the sa_make_object system procedure to add a skeleton web service.

Parameters 

object-type    The type of object being created. The parameter must be one of 'procedure', 'function', 'view', 'service'or 'trigger'.

objname    The name of the object to be created.

owner    The owner of the object to be created. The default value is CURRENT USER.

tabname    required only if objtype is 'trigger', in which case it specifies the name of the table on which the trigger is to be created.

Example 

The following statements ensure that a skeleton procedure definition is created, define the procedure, and grant permissions on it. A command file containing these instructions could be run repeatedly against a database without error.

CALL sa_make_object( 'procedure','myproc' );
ALTER PROCEDURE myproc( in p1 int, in p2 char(30) )
BEGIN
    // ...
END;
GRANT EXECUTE ON myproc TO public;

The following example uses the sa_make_object system procedure to add a skeleton web service.

CALL sa_make_object( 'service','my_web_service' )

Contents Index sa_locks system procedure sa_migrate system procedure