exec_proc

Executes a database stored procedure statement.

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL
X X X X X

Syntax

int exec_proc(statement[[,variable-name,data,flags]...])
string        statement, variable-name
expr          data, flags

Description

Executes the specified stored procedure, returning 0 if completed successfully. If an error occurs, and exec_proc() is part of the expression, the function returns -1.

If exec_proc() isn't part of the expression, the function escapes to the window trigger error trap or, for reports or stand-alone TRIMpl, the operating system command shell. Not all databases support stored procedures. Furthermore, only Oracle accepts array parameters. If you pass arrays to a database that does not support them, the database returns an error.

statement specifies the procedure to execute. Multiple statements can exist.

variable-name (optional) specifies the name of a given argument.

data (optional) must be a TRIMpl variable if the argument is an output variable.

flags (optional) indicates whether the variable is an input and/or an output variable. flags possible values are:
  • 1 --- Input
  • 2 --- Output
  • 3 --- Both input and output (bitwise OR of Input and Output)

and are defined in header files (trim.h or gui.h).

Example

Accesses a function that has been stored in an Oracle database.
{
int i,j,k;

for (i=4,j=4;i;i--) {
  exec_proc("begin :arg0 := sample6.add_func(:arg1, :arg2); end;",
            ":arg0",k,2,":arg1",i,1,":arg2",j,3);
  printf("i: " ^^ i ^^ ", j: " ^^ j ^^ ", k: " ^^ k);
  }
}