describing update statements in ESQL/C
Posted in 1993
Hi.
I'm trying to write a general purpose sql interpreter embedded in the
interpreted language perl (isqlperl 1.2) When I finish it, It will be
released under the GNU Public License, as is isqlperl 1.1. Of
course you still need to buy ESQL/C to build it :-).
Anyway mostly I'm OK, I've tried very hard to stay within the
documented scope of ESQL/C, and I'm targetting initially at ISQL 4.10
OnLine and SE, but I have hit what seems to be a pretty major snag.
I can $describe a select statement, and get back the sqlda with the
sqlvar_struct array of data types being returned by the select.
I can force all of these values to CCHAR_TYPE, with appropriate lengths,
except BLOBs, for which I can allocate locators and treat specially
(perl supports binary data which can be coerced to BYTE.)
Similarily I can count the number of `?' characters in the select and
allocate another sqlda/sqlvar_struct construct to pass in the host
variables to the where-clause, all coerced to strings, when I open the
select cursor.
No problems with inserts either, I can $describe an insert statement,
and get back an sqlda with the expected input data types, which I can
coerce to strings, except for BLOBs, for which, again, I can
allocate locator structs and treat specially.
My problem is with updates. If I $describe an update statement into an
sqlda, then even though the update has `?' placeholders, the sqlda.sqld
(number of columns) is zero. I can of course count the `?' characters
and allocate my own sqlvar_struct array, of all CCHAR_TYPE data, but
then I can't pass in BLOBs to an update statement.
What's the trick? I need to create a properly instantiated sqlda for a
parameterised update statement, in order to look for potential BLOB
data in it. Otherwise I can't UPDATE BLOB data. I know the ESQL/C
manual says that you will have to parse the statement in order to
determine not only the number, but also the types of the parameters,
but surely a library routine exists to do this for you, even if it's
undocumented.
Any help would be greatly appreciated. Basically, I'm stumped.
--
Cheers
Bill
===========================================================================
| Bill Hails <bill@tardis.co.uk> | Reisner's rule of conceptual inertia: |
| C.L.I. Connect Ltd. | |
| 19, Quarry St., Guildford, Surrey | If you think big enough, you'll never |
| GU1 3UY. Tel (UK) 0483 300 200 | have to do it. |
===========================================================================