Executing SQLEXEC within a TABLE or MAP Statement
When used within a TABLE
or MAP
statement, SQLEXEC
can pass and accept parameters. It can be used for procedures and queries, but not for database commands.
Syntax
This syntax executes a procedure within a TABLE
or MAP
statement.
SQLEXEC (SPNAMEsp_name
, [IDlogical_name
,] {PARAMSparam_spec
| NOPARAMS})
Argument | Description |
---|---|
SPNAME |
Required keyword that begins a clause to execute a stored procedure. |
|
Specifies the name of the stored procedure to execute. |
|
Defines a logical name for the procedure. Use this option to execute the procedure multiple times within a |
PARAMS |
Specifies whether or not the procedure accepts parameters. One of these options must be used (see Using Input and Output Parameters). |
Syntax
This syntax executes a query within a TABLE
or MAP
statement.
SQLEXEC (IDlogical_name
, QUERY 'query
', {PARAMSparam_spec
| NOPARAMS})
Argument | Description |
---|---|
|
Defines a logical name for the query. A logical name is required in order to extract values from the query results. |
QUERY ' |
Specifies the SQL query syntax to execute against the database. It can either return results with a SQLEXEC 'SELECT "col1" from "schema"."table"' |
PARAMS |
Defines whether or not the query accepts parameters. One of these options must be used (see Using Input and Output Parameters). |
If you want to execute a query on a table residing on a different database than the current database, then the different database name has to be specified with the table. The delimiter between the database name and the tablename should be a colon (:
). The following are some example use cases:
select col1 from db1:tab1 select col2 from db2:schema2.tab2 select col3 from tab3 select col3 from schema4.tab4