sqldynprep() — Prepare a Dynamic SQL Statement

Prepare a dynamic SQL statement. This function supports the dynamic EXEC SQL PREPARE... statement.

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

SYNTAX
int
sqldynprep ( sqln, prequest, pstmtid )
  SQLRQHDL    **sqln;       /* OUTPUT */
  char        *prequest;    /* INPUT */
  char        *pstmtid;    /* INPUT */ 

sqln

The address of a pointer to the request handle value associated with and returned for the statement being prepared. If the function returns successfully, you can use sqln for subsequent calls to ESQL-LIB to refer to this statement. For more information on request handles, see the "SQL Request Handles" section.

prequest

A pointer to the text of the SQL statement being prepared.

pstmtid

A pointer to a NULL-terminated string that contains the SQL statement identifier (limited to 18 characters). If you use the preprocessor, it supplies this value. Otherwise, it can be NULL. If you set it to NULL, sqlgetrqhdl() cannot return the request handle corresponding to the statement identifier.

NOTES

EXAMPLE

This example prepares the dynamic ESQL cursor specification in the character string request:

#include "proesql.h"
static SQLRQHDL *sql1 = (SQLRQHDL *) 0;
            .
            .
            .
char *request= "SELECT * FROM customer";

/* EXEC SQL PREPARE DEMOSTMT FROM request; */

{
    sqlcdbind(&SQLCODE, (char *)0);
    sqldynprep(&sql1, request, "DEMOSTMT");
}
if (SQLCODE < 0)
{
  printf("Error preparing cursor SELECT\n");
  return;
} 

SEE ALSO

sqldyndesc() — Get Dynamic Column Descriptions, sqldynexec() — Execute a Dynamic SQL Statement, sqldynncols() — Get the Number of Columns in a Result Set, sqldynnparms() — Get the Number of Parameter Markers


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