Esql/C Set Descriptor
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
I'm having trouble setting a descriptor for numeric types. I get a message that says: "Character to numeric conversion error." Here's what I'm doing: // allocate descriptor area, set count long l = 34; EXEC SQL BEGIN DECLARE SECTION; int index = 1; int type = SQLINT; char* data = &l; char* da_name = "mydesc"; EXEC SQL END DECLARE SECTION; EXEC SQL SET DESCRIPTOR :da_name VALUE :index TYPE = :type, DATA = :data; // check for errors by looking at SQLSTATE, // call GET DIAGNOSTICS, and I get IX000 "Character to numeric // conversion error." Everthing thing works fine if I use character data. It seems like its treat my long pointer as a string, and convert it to a number. How can I avoid that, and pass it a pointer to numeric data directly? Or is that not possible? Thanks. -- Steve Molitor smolitor@erac.com "Emacs is the Computer"
Replying to myself -- If I convert numeric data to strings, then set descriptor data works. But that seems kind of redundant. I convert numeric data to strings, and then esql/c informix translates the data back to a number. Is there a way to avoid that, to pass numeric data in directly? (You can with cli/odbc). -- Steve Molitor smolitor@erac.com "Emacs is the Computer"
Hi Steve, I think you should not use the char pointer for your long variable. Isn't it possible to use a long for the data-var ? And a pointer to the value is wrong too. HTH Dirk Steve Molitor schrieb: > I'm having trouble setting a descriptor for numeric types. I get a > message that says: "Character to numeric conversion error." > > Here's what I'm doing: > > // allocate descriptor area, set count > > long l = 34; > > EXEC SQL BEGIN DECLARE SECTION; > int index = 1; > int type = SQLINT; > char* data = &l; > char* da_name = "mydesc"; > EXEC SQL END DECLARE SECTION; > > EXEC SQL SET DESCRIPTOR :da_name VALUE :index > TYPE = :type, > DATA = :data; > > // check for errors by looking at SQLSTATE, > // call GET DIAGNOSTICS, and I get IX000 "Character to numeric > // conversion error." > > Everthing thing works fine if I use character data. It seems like its > treat my long pointer as a string, and convert it to a number. How can > I avoid that, and pass it a pointer to numeric data directly? Or is > that not possible? > > Thanks. > > -- > Steve Molitor > smolitor@erac.com > "Emacs is the Computer"