sqldyngetn() — Get a Cursor Name

Gets the cursor name currently associated with the prepared dynamic ESQL statement that a request handle specifies.

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

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

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

The address of a memory location to receive the cursor name. The memory must be at least ESQL_MAXCURSNAME + 1 bytes long (the extra byte for the NULL terminator).

NOTES

EXAMPLE

This example prepares a cursor specification and declares a cursor for it using the DECLARE statement. After opening the cursor and fetching a row (not shown), the example retrieves the name of the cursor in cursorname and uses it in a positioned UPDATE request that sets the customer name in the current row to NULL:

#include "proesql.h"
static SQLRQHDL *sql0 = (SQLRQHDL *) 0;
static SQLRQHDL *sql1 = (SQLRQHDL *) 0;
static long      SQLCODE;
char        request[80];
char        cursorname[ESQL_MAXCURSNAME + 1];
            .
            .
            .
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");
}
            .
            .
            .
sqlcdbind(&SQLCODE, (char *)0);
sqldyngetn(sql0, cursorname);
if (SQLCODE < 0)
{
  printf("Error getting cursor for request\n");
  sqldynclose(sql0, SQL_STMTDROP);
  return;
}

sprintf( request,
      "UPDATE customer SET name = NULL WHERE CURRENT OF %s",
      cursorname
    );
sqlcdbind(&SQLCODE, (char *)0);
sqldynrq(&sql1, request);
if (SQLCODE < 0)
{
  printf("Error executing immediate request\n");
  return;
} 

SEE ALSO

sqldynexec() — Execute a Dynamic SQL Statement, sqldynsetn() — Define a Cursor Name, proesql.h


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