Pro*C & variables
From: Bert Vanderstraeten <bvds_at_hotpop.com>
Date: Mon, 18 Oct 1999 20:03:57 +0200
Message-ID: <1mJO3.135$_L4.343_at_news-brussels.gip.net>
==> EXEC SQL DECLARE cursorname CURSOR FOR db_stmt;
Date: Mon, 18 Oct 1999 20:03:57 +0200
Message-ID: <1mJO3.135$_L4.343_at_news-brussels.gip.net>
Hi,
I'm trying to get the following piece of code to work:
It's a C-function that declares a cursor with a name based on a variable:
static void create_cursor ( )
{
EXEC SQL BEGIN DECLARE SECTION; varchar hv_dataname[ 21]; varchar hv_currstmt[500]; EXEC SQL END DECLARE SECTION; hv_dataname.len = sprintf( (char *) hv_dataname.arr, "%.20s", db ); hv_currstmt.len = sprintf( (char *) hv_currstmt.arr, "SELECT empno FROM emp " ); [Quoted] EXEC SQL DECLARE db_stmt STATEMENT; EXEC SQL PREPARE db_stmt FROM :hv_currstmt;
==> EXEC SQL DECLARE cursorname CURSOR FOR db_stmt;
/* how can I use a variable name as cursorname in this last statement?
a :cursorname host variable does NOT work */
}
Thanks a million in advance!
Bvds
Received on Mon Oct 18 1999 - 20:03:57 CEST