Structured Query Scripting Language interpreter API reference


file csqpc.c
int fgw_sqlexec(i_query, i_size, def_fd, flags, width, vars, txtvar)
char *i_query;					/* input: script */
int i_size;					/* input: script size */
int def_fd;					/* input: output file descriptor */
int flags;					/* input: execution flags */
int width;					/* input: output width */
loc_t *vars;					/* IO: symbol table */
loc_t *txtvar;					/* output: script output */
return value sql error returned by the script
purpose fgw_sqlexec Implements the structured query scripting language interpreter
example none
  • def_fd is any valid stream open for writing, or 0 to signify that the default output should go to txtvar. On exit the stream is left open.
  • flags is any combination of the following:
    • K_html produces a simple but effective html output
    • K_verbose flags that status information should be displayed
    • K_isbatch signals that interactive expansions (picklists and prompts) should not be allowed
    • K_errorcont has the same effect as whenever error continue
    • K_dml flags that DML/DDL statements are allowed
    • K_noconf specifies that no confirmation should be asked to the user before executing DML/DDL statements
    • K_preserve specifies that variables and sql resources should be preserved across invocations. Use fgw_sqlrelease to release resources at the end of the session
    constants are defined in csqpc.h
  • When K_preserve has been used, it is important not to dispose of the vars byte variable before having called fgw_sqlrelease: any such action will ultimately result in a SQL resources and memory leak
  • When using K_preserve and executing multiple scripts from the same process, it is important to realize that scripts might affect each others connections: altough named connections are private to each script, the default connection is not, and it is possible for a script to close a database on the default connection that another script expects to be the current database. This has furthermore implications on the second script prepared statements. In order to avoid conflicts, it is best that invocations using the K_preserve flag (eg the SQSL interpreter viewer) switch to a named connection before proceeding with anything else. By the same token, it is suggested that invocations not using the K_preserve flag switch to the default connection, and for good measure, reopen the desired database
  • the behaviour of the expansion facility (and in particular the ability to use pick lists) depends on the user interface in use. See fgw_sqlexplode for more information


file cexpc.c
int fgw_sqlexplode(src, srclen, vars, verbose, expstate, iidx, oodx,
		   exp, s, e, explen)
char *src;				/* Input: script */ 
int srclen;				/* Input: script length */
loc_t *vars;				/* IO: symbol table */
int verbose;				/* Input: verbose flag */
int expstate;				/* Input: expansion flag */
int iidx;				/* Input: start offset */
int *oidx;				/* Output: next start offset */
char *exp;				/* Output: buffer containing expansion */
int *s;					/* Output: start index of verbatim string */
int *e;					/* Output: end index of verbatim string */
int explen;				/* Input: buffer size */
return value sql error returned by the script
purpose Implements the expansion facility
example none
  • iidx should initially be 1, and the value returned by oidx on successive calls
  • at each successive call fgw_sqlexplode will either return the result of an expansion, in exp, or a portion of the source string to be copied verbatim (starting at s and ending at e)
  • the end of the query is marked by oidx being set to NULL
  • expstate is at present used in conjunction with the fgw_sqlexec. If set to zero, it allows to skip actions on expansion blocks (eg because in inactive sections of the input script), if set to -1, interactive expansions (picklists and prompts) are disabled
  • the expansion facility does not allow the use of pick lists if the application is not running (or has been linke not to run) in form mode.


file csqpc.c
void fgw_sqlrelease(vars)
loc_t	*vars;				/* hash containing vars & resource info */
returns nothing
purpose Releases resources used by sql scripts executed with the K_preserve flag in effect.
example none
notes see fgw_sqlexec

Please address questions or comments to Marco Greco
(last updated Mon, 19 September 2016 15:36:05 BST)