sqldynsetn() — Define a Cursor Name

Defines and associates a cursor name with a prepared dynamic ESQL statement. This function supports the dynamic EXEC SQL DECLARE... statement.

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

SYNTAX
int
sqldynsetn ( sqln, pname )
  SQLRQHDL    *sqln;    /* INPUT */
  char         *pname;      /* INPUT */ 

sqln

A pointer to the request handle that a previous call to sqldynprep() returns. For more information on request handles, see the "SQL Request Handles" section.

pname

A pointer to a NULL-terminated string that contains a cursor name (limited to 18 characters) to associate with the SQL statement to which sqln refers. If you use the preprocessor, it supplies this value.

NOTES

EXAMPLE

This example prepares a cursor specification and declares a cursor for it using the DECLARE statement, converted to a call to sqldynsetn(). It also shows how you can use the declared cursor to execute a positioned UPDATE:

#include "proesql.h"
static SQLRQHDL *sql0 = (SQLRQHDL *) 0;
static SQLRQHDL *sql1 = (SQLRQHDL *) 0;
static long  SQLCODE;
char  cursorname[ESQL_MAXCURSNAME + 1];
char  *request="UPDATE customer SET name=NULL WHERE CURRENT OF C1";
            .
            .
            .
sqlcdbind(&SQLCODE, (char *)0);
sqldynprep(&sql0, "SELECT * FROM customer", "STMT5");
if (SQLCODE < 0)
  return;

/* EXEC SQL DECLARE C1 CURSOR FOR STMT5; */
{
  sqlcdbind(&SQLCODE, (char *)0);
  sqldynsetn(sql0, "C1");
}
if (SQLCODE < 0)
{
  printf("Error setting cursor for SELECT\n")
  return;
}
            .
            .
            .

sqlcdbind(&SQLCODE, (char *)0);
sqldynrq(&sql1, request); 

SEE ALSO

sqldynexec() — Execute a Dynamic SQL Statement, sqldynprep() — Prepare a Dynamic SQL Statement, sqldyngetn() — Get a Cursor Name


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