Bug #33471 Operation Not Applicable
Submitted: 21 Dec 2007 21:07 Modified: 9 Jan 2008 14:37
Reporter: Diego Lopez Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.22 OS:Microsoft Windows (XP SP2)
Assigned to: CPU Architecture:Any
Tags: Borland, Builder, C++

[21 Dec 2007 21:07] Diego Lopez
Description:
The following query (Borland C++ Builder Enterprise 6.0 BDE) works with version 3.51.02 but not with 3.51.22:

  DMInventario->SQLTransaccion->SQL->Clear();
  DMInventario->SQLTransaccion->SQL->Add("select td.signo, tr.cantidad from transaccion tr, tipodoc td ");
  DMInventario->SQLTransaccion->SQL->Add("left join tipodoc td on tr.tipdoc= td.tipdoc");
  DMInventario->SQLTransaccion->SQL->Add("left join documento doc on tr.tipdoc=doc.tipdoc and tr.numdoc= doc.numdoc");
  DMInventario->SQLTransaccion->SQL->Add("where doc.tipdoc is not null");
  DMInventario->SQLTransaccion->SQL->Add("and tr.codpro= :codigo");
  DMInventario->SQLTransaccion->SQL->Add("and tr.fecha< :fechai");
  DMInventario->SQLTransaccion->SQL->Add("and (td.signo= '+' or td.signo='-')");
  DMInventario->SQLTransaccion->SQL->Add("order by tr.fecha ");
  DMInventario->SQLTransaccion->ParamByName("codigo")->AsString = codpro->Text;
  DMInventario->SQLTransaccion->ParamByName("fechai")->AsDateTime = dtfechaini;
  DMInventario->SQLTransaccion->Prepare();
  DMInventario->SQLTransaccion->Open();

When the program opens the connection an exception throws saying "Operation not applicable"

How to repeat:
Try the same query in Borland C++ Builder Enterprise ver 6.0 you will three tables.
[26 Dec 2007 15:19] Diego Lopez
Sorry, there is a mistake in the first line of the select statement. Should be like this: (I was making several changes to the statement when I submitted the bug to see if it works).

DMInventario->SQLTransaccion->SQL->Clear();
  DMInventario->SQLTransaccion->SQL->Add("select td.signo, tr.cantidad from transaccion tr");
  DMInventario->SQLTransaccion->SQL->Add("left join tipodoc td on tr.tipdoc= td.tipdoc");
  DMInventario->SQLTransaccion->SQL->Add("left join documento doc on tr.tipdoc=doc.tipdoc
and tr.numdoc= doc.numdoc");
  DMInventario->SQLTransaccion->SQL->Add("where doc.tipdoc is not null");
  DMInventario->SQLTransaccion->SQL->Add("and tr.codpro= :codigo");
  DMInventario->SQLTransaccion->SQL->Add("and tr.fecha< :fechai");
  DMInventario->SQLTransaccion->SQL->Add("and (td.signo= '+' or td.signo='-')");
  DMInventario->SQLTransaccion->SQL->Add("order by tr.fecha ");
  DMInventario->SQLTransaccion->ParamByName("codigo")->AsString = codpro->Text;
  DMInventario->SQLTransaccion->ParamByName("fechai")->AsDateTime = dtfechaini;
  DMInventario->SQLTransaccion->Prepare();
  DMInventario->SQLTransaccion->Open();
[7 Jan 2008 2:35] Diego Lopez
Sorry if I'm being over anxious, any news  regarding this bug?
[9 Jan 2008 9:31] Tonci Grgin
Hi Diego and thanks for your report. Sorry for delay in processing due to holiday season. I believe this is a known problem with Borland tools, you can check on my workaround and Bogdan's explanation in Bug#18084. There are also a lot of reports in BugsDB you can check on, like #1026 ...
[9 Jan 2008 14:29] Diego Lopez
Thanks Tonci. After reading bug 18084, and the discussion about if it is not or not a bug, I think my vote is for the bug. The reason is that with the version 3.51.02 the statement DOES work. 

I will close this bug but I will add my two cents in bug 18084.
[9 Jan 2008 14:37] Tonci Grgin
Diego, the fact that 3.51.02 works makes no difference on our ruling... The only right thing to do would be for CodeGear to fix BDE calling v3 functions after presenting itself as v2 client but that would not happen as BDE is abandoned. I would like to see stable dbExpress driver for MySQL and I'm working on making that happen actively.
Marking this report as a duplicate of Bug#18084.