embedded sql problem with INDICATOR
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi all,
We've got a problem. We are getting bad code generated by the
esql.exe pre-compiler. I am upgrading a system from VC++4.2 to 5.0.
The old system used esql.exe version 7.20.
We are now running esql.exe version 9.14 under WinNT 4.0.
Our command line options are: -thread -p -icheck
An extra close parenthesis is inserted after a "sizeof" function call.
I figure it has to do with the char string and INDICATOR. Has anybody seen
this problem before?
Many thanks,
Josh
jmales at ndsisrael dot com
Here is the original SQL code:
EXEC SQL BEGIN DECLARE SECTION;
char szName[256];
char szPath[256];
char szDescription[256];
char szLongDescription[256];
short int shPathInd;
short int ushTypeNo;
short int ushScriptNo;
EXEC SQL END DECLARE SECTION;
EXEC SQL
SELECT script_type_no,
script_name,
script_path,
script_descn,
script_long_descn
INTO :ushTypeNo,
:szName,
:szPath INDICATOR :shPathInd,
:szDescription,
:szLongDescription
FROM Script
WHERE script_no = :ushScriptNo;
------------------------------------------
The generated code looks like this:
#line 47 "scriptdb.ec"
{
#line 47 "scriptdb.ec"
static const char *sqlcmdtxt[] =
#line 47 "scriptdb.ec"
{
#line 47 "scriptdb.ec"
" SELECT script_type_no , script_name , script_path , script_descn ,
script_long_descn FROM Script WHERE script_no = ?",
0
};
#line 59 "scriptdb.ec"
ifx_cursor_t _SQ0;
ifx_sqlda_t *_SD0;
ifx_sqlda_t *_SD1;
_SD1 = (ifx_sqlda_t *) sqli_mt_alloc_osqlda(ESQLINTVERSION,5);
sqli_mt_obind(101, (char *) &ushTypeNo, sizeof(ushTypeNo), 0, 0, 0, 0,
(char *)0, 0, (char *)0, 0, (char *)0, 0, 0);
sqli_mt_obind(100, szName, 256, 0, 0, 0, 0, (char *)0, 0, (char *)0, 0,
(char *)0, 0, 0);
================================================================
This next line has the error. Look at sizeof. Why is there
an extra ) ?
sqli_mt_obind(100,
szPath,
256,
101,
(char *) &shPathInd,
sizeof(shPathInd)),
0, (char *)0, 0, (char *)0, 0, (char *)0, 0, 0);
================================================================
sqli_mt_obind(100, szDescription, 256, 0, 0, 0, 0, (char *)0, 0, (char
*)0, 0, (char *)0, 0, 0);
sqli_mt_obind(100, szLongDescription, 256, 0, 0, 0, 0, (char *)0, 0,
(char *)0, 0, (char *)0, 0, 0);
_SD0 = (ifx_sqlda_t *) sqli_mt_alloc_isqlda(ESQLINTVERSION,1);
sqli_mt_ibind(101, (char *) &ushScriptNo, sizeof(ushScriptNo), 0, 0, 0,
0, (char *)0, 0, (char *)0, 0, (char *)0, 0, 0);
byfill((char *) &_SQ0, sizeof(_SQ0), 0);
#line 59 "scriptdb.ec"
sqli_slct(ESQLINTVERSION, &_SQ0, (char **) sqlcmdtxt, 1, (ifx_sqlvar_t *)
_SD0->sqlvar, 5, (ifx_sqlvar_t *) _SD1->sqlvar, 1, (ifx_literal_t *) 0,
(ifx_namelist_t *) 0, 0);
#line 59 "scriptdb.ec"
}