Bug #1700 Decimal Input parameters on a query causes error at
Submitted: 29 Oct 2003 6:00 Modified: 30 May 2013 8:27
Reporter: Stephen Dakin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:4.0.16 OS:Any (NT)
Assigned to: CPU Architecture:Any

[29 Oct 2003 6:00] Stephen Dakin
Description:
The following error appears:

[MySQL][ODBC 3.51 Driver][mysqld-4.0.16-nt]You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
SQL State: 42000
Native: 1064
 Executing: 'SELECT Containers.TAG, Containers.CLASS_ID, Containers.EDIT_ID, Containers.ORIGIN, Containers.DESTINATION, Containers.CREATEDDT, Containers.STATUS, Containers.WEIGHT, Containers.CWB, Containers.CWBSOURCEID, Containers.CONTAINERTAG, Containers.POSSESSEDBY FROM Containers WHERE CWB = ? '

At the time when the first parameter is bound (call to SQLBindColumn)
Under the following circumstances:
1) This is the first time that a statement has been prepared with an input parameter which is DECIMAL(19,4) on THIS TABLE 
2) The input parameters are bound before the columns are bound. 

IE
Prepare (SQLPrepare)
Bind Parameters (SQLBindParameter)
Bind Columns (SQLBindColumn) ' At the First column binding this throws the above error.
Execute (SQLExecute)

NO error happens if the order is changed to 

Prepare (SQLPrepare)
Bind Columns (SQLBindColumn)
Bind Parameters (SQLBindParameter)
Execute (SQLExecute)

How to repeat:
1) Build the table def below. 
2) Prepare the SQL in the description just after the ODBC Driver error (which looks to originate from the engine to me) on a statement (SQLPrepare)
3) Bind the Input Parameter SQLBindParameter 
fParamType = SQL_PARAM_INPUT
fcType = 1
fSQLType = 2
cbColDef = 19
ibScale = 4
cbValueMax = 0
4) Bind the first result column (Tag) using SQLBindColumn
fcType = -16 = SQL_C_SLONG
BufferLen = 4

Here is a table definition:
CREATE TABLE `containers` (
  `Tag` int(11) default NULL,
  `Class_Id` smallint(6) default NULL,
  `Edit_Id` smallint(6) default NULL,
  `Origin` char(6) default NULL,
  `Destination` char(6) default NULL,
  `CreatedDT` datetime default NULL,
  `Status` smallint(6) default NULL,
  `Weight` int(11) default NULL,
  `CWB` decimal(19,4) default NULL,
  `CWBSOURCEID` smallint(6) default NULL,
  `ContainerTag` int(11) default NULL,
  `PossessedBy` char(6) default NULL,
  UNIQUE KEY `ContainerTagi` (`Tag`),
  UNIQUE KEY `ContainerCWB` (`CWB`,`CWBSOURCEID`),
  KEY `ContainerConti` (`ContainerTag`),
  KEY `ContainerOrigini` (`Origin`),
  KEY `ContainerDesti` (`Destination`),
  KEY `ContainerCreatedi` (`CreatedDT`)
) TYPE=MyISAM;
[19 Jan 2004 15:48] Miguel Solorzano
I tried with my own code and wasn't able to repeat.
Could you please provide me the program code for further
tests at my side. Thanks.
[30 May 2013 8:27] Bogdan Degtyariov
I'm closing this bug because I can not continue without feedback from the reporter. If you have new info, please reopen the report.