sqlgetrqhdl() — Get a Dynamic Request Handle

Gets a request handle corresponding to a prepared dynamic ESQL statement identifier.

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

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

pstmtid

A pointer to an SQL statement identifier used in dynamic ESQL statements and registered to the ESQL-LIB interface with a previous call to sqldynprep().

sqln

The address of a pointer to the request handle corresponding to the specified statement identifier. For more information on request handles, see the "SQL Request Handles" section.

NOTE

EXAMPLE

This example retrieves the request handle for a prepared cursor specification in order to get the number of parameter markers in the request. The example assumes that you have prepared the request using the PREPARE statement, before the preprocessor has defined and returned the request handle to sql1. However, the code itself is preprocessed, and that is why rqhandle, to which sqlgetrqhdl() returns the same request handle, appears redundant. If you call ESQL-LIB directly to implement dynamic SQL requests, you define and use your own request handle variables from the beginning and do not need to call sqlgetrqhdl():

#include "proesql.h"
static SQLRQHDL *sql1 = (SQLRQHDL *) 0;
            .
            .
            .
SQLRQHDL  *rqhandle;
int    nparms;

char *request="SELECT * FROM customer WHERE credit-\limit > ?";

/* EXEC SQL PREPARE DEMOSTMT FROM request; */

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

sqlcdbind(&SQLCODE, (char *)0);
sqlgetrqhdl( "DEMOSTMT", &rqhandle );
if (SQLCODE < 0)
{
  printf("Error getting request handle\n");
  return;
}
sqlcdbind(&SQLCODE, (char *)0);
sqldynnparms(rqhandle, &nparms); 

In this example, the parameter markers in the request are hard-coded to show their presence. In reality, the request string might be conditionally assembled from several code points, making the presence and number of parameter markers truly unknown when the request is prepared.

SEE ALSO

sqldynprep() — Prepare a Dynamic SQL Statement, sqldynnparms() — Get the Number of Parameter Markers


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