CliPreSQLExt is the CLI Pre-process SQL User Exit function of DBCHCL. CliPreSQLExt is used to filter SQL requests that may slow down the Teradata Database, to control SQL requests sent to the Teradata Database and to collect time statistics of SQL requests.
Calling CliPreSQLExt
CliPreSQLExt is called just before CLIIRQ. Prior to the call to CliPreSQLExt, CLI performs the following:
- If not variable length request, CLI checks the SQL request to see if it can be saved in the internal CLI Buffer.
If the request length is less than, or equal to, the internal max buffer length, the process will continue to the next step. If not, it will abort and return an error 302.
- The SQL request’s length is saved in the structure CliPreSQLExt.
If the request length is less than, or equal to, the internal buffer size, the process will continue to the next step. If not, it will abort and return an error 302.
- After the call to CliPreSQLExt, CLI performs the following:
- If EM_OK was returned, send the Teradata SQL to the Teradata Database.
- If an error message is received, abort the request. Use normal CLI error logic when a Teradata SQL request is aborted.
Interface
struct CliPreSQLExit { char *SQL_Request_ptr; /* pointer to user request */ char Start_date[80]; /* start date in ascii */ Int32 Clock_time; /* clock time */ char dbcname[DBCNAMLEN]; /* DBC name */ char username[USRNAMLEN]; /* username */ char account[ACTNAMLEN]; /* account */ char password[PWDNAMLEN]; /* password */ char domain[DOMAINLEN]; /* domain */ Int32 *SQL_len_ptr; /* length of user request */ Int32 logsessid; /* logical session id */ Int16 Process_Post; /* enable post processing */ };
The elements Start_date[80] and Clock_time must be set manually to determine the clock time for SQL requests.
Return Value
CliPreSQLExt returns zero (0) if successful, otherwise it returns an error code. The variable Process_Post is set to TRUE if the Post-process SQL function is to be executed by CLI.
Error Handling
A CLI error code 351 (SQLUSREXT) is available to the user. However, any error code found in the errmsg.txt file may also be returned.