sqlrequest() — Execute a Static ESQL Statement

Executes any static ESQL statement, except positioned UPDATE and DELETE. This function supports any non-positioned static ESQL statement or cursor specification (EXEC SQL DECLARE...CURSOR FOR SELECT and OPEN... statements). If you precompile the statement, the preprocessor generates the r-code file to run it.

This function returns normalized values. For more information, see the function return values in the "General Diagnostics" section in this chapter:

SYNTAX
int
sqlrequest ( sqln, flag, prequest, pcursnam, pvformat, psqlv)
  SQLRQHDL  **sqln;    /* OUTPUT */
  int       flag;        /* INPUT */
  char      *prequest;    /* INPUT */
  char      *pcursnam;    /* INPUT */
  char      *pvformat;    /* INPUT */
  char      *psqlv[];    /* INPUT */ 

sqln

The address of a pointer to a request handle value associated with and returned for the statement. If the statement is an open cursor statement, this argument tracks all statements for the cursor. For more information on request handles, see the "SQL Request Handles" section.

flag

An execution flag that ESQL initializes.

prequest

A pointer to the text of the statement. If you precompile the statement, the text contains the name of the r-code file associated with the statement.

pcursnam

A pointer to the name of the cursor for the statement. If it is a non-cursor request, the pointer resolves to a null string.

pvformat

A pointer to a format string that describes the types and lengths of the embedded host variables.

psqlv

A pointer to the host variables to which the current SQL request refers.

EXAMPLE

This example opens cursor x (associated with request handle sql0) for the customer table, and selects all rows of the specified columns, where column cust-num is greater than the local variable hicustnum:

#include "proesql.h"
static SQLRQHDL *sql0 = (SQLRQHDL *) 0;
            .
            .
            .
    /* EXEC SQL BEGIN DECLARE SECTION; */
    . . . long  . . . hicustnum; . . .
    /* EXEC SQL END DECLARE SECTION; */
    hicustnum = 7;
            .
            .
            .
    /* EXEC SQL declare x cursor for
        select cust\-num, name, city, st, max\-credit from customer
            where cust\-num < :hicustnum; */
    /* EXEC SQL OPEN x; */
    {
static char sqltxt[] = {
’d’,’e’,’c’,’l’,’a’,’r’,’e’,’,’x’,’,’c’,’u’,’r’,’s’,’o’,’r’,’ ’,
’f’,’o’,’r’,’,’s’,’e’,’l’,’e’,’c’,’t’,’,’c’,’u’,’s’,’t’,’-’,’’n’,’u’,’m’,
’,’,’,’n’,’a’,’m’,’e’,’,’,’,’c’,’i’,’t’,’y’,’,’,’ ’,
’s’,’t’,’,’,’,’m’,’a’,’x’,’-’,’c’,’r’,’e’,’d’,’i’,’t’,’,’f’,’’r’,’o’,’m’,
’,’c’,’u’,’s’,’t’,’o’,’m’,’e’,’r’,’,’w’,’h’,’e’,’r’’,’e’,’,
’c’,’u’,’s’,’t’,’-’,’n’,’u’,’m’,’,’<’,’,’e’,’s’,’q’,’l’’,’i’,’0’,’.’,0};
static char sqlfmt[] = {’,’,’4’,’l’,0};
static char *sqlv[2];
       sqlv[0] = (char *) &hicustnum;
       sqlv[1] = (char *) 0;
       sqlcdbind(&SQLCODE, (char *)0);
       sqlrequest(&sql0,(int)0x04,sqltxt,"x",sqlfmt, sqlv);
       if (SQLCODE < 0) goto err;
            .
            .
            .
    } 

SEE ALSO

sqldelrow() — Delete Row at Open Cursor for executing positioned DELETE statements, sqldynexec() — Execute a Dynamic SQL Statement for executing dynamic requests, sqldynprep() — Prepare a Dynamic SQL Statement for compiling dynamic requests, sqldynrq() — Execute a Dynamic Non-SELECT Statement for compiling and executing dynamic non-SELECT statements, sqlfetch() — Fetch Next Row of Open Cursor for fetching rows of static cursors, sqlupdrow() — Update Row at Open Cursor for executing static positioned UPDATE statements.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095