Page 1 of 1

TMyQuery execution error

Posted: Thu 24 Apr 2008 20:52
by Wilton
Hi,
After install MySQL Professional Edition 5.20.1.15 with BDS 2006, i'm receive this error when i execute one single querie.
Could not convert variant of type (OleStr) into type (Date)
The code used in this querie is :

Code: Select all

 
SELECT
sum( if(bsp is null,0,bsp)-IF(assumido IS NULL,0,assumido) )as devido,
 (SELECT SUM(b.fatbsp) FROM bspfatura b WHERE b.dtbsp = :dtbsp  AND cia=bspfatura.cia AND b.nfaturabsp IS NULL GROUP BY b.cia) as semfatura, /* tkt não cobrado */
 sum(IF(assumido IS NULL,0,assumido)) as assumido,
 sum(if(bsp is null,0,bsp)-
IF((SELECT b.saldo  FROM bspfatura b WHERE b.dtbsp = :dtbsp  AND b.cia=bspfatura.cia AND b.numero=bspfatura.numero AND b.nfaturabsp IS NULL GROUP BY b.cia) IS NULL,0, 
     (SELECT b.saldo FROM bspfatura b WHERE b.dtbsp = :dtbsp  AND b.cia=bspfatura.cia AND b.numero=bspfatura.numero AND b.nfaturabsp IS NULL GROUP BY b.cia))
)as bsp,           /*saldo devido*/

 sum(if( pago is null,0,pago)) as pago,      /*Já pago*/
 sum(if(saldo is null,0,saldo)) as saldo,    /*A pagar*/
 sum(if(fatbsp is null,0,fatbsp)) as fatbsp, /*fatura*/
 sum( if(diferenca is null,0,diferenca)) as diferenca,
 (SELECT ciacode.nomecia FROM ciacode WHERE ciacode.codigo=bspfatura.cia) as cia,
 dtbsp,
 sum(txus) as txus, 
 sum(txrs) as txrs, 
 sum(txseg) as txseg, 
 sum(txsegrs) as txsegrs, 
 sum(vlbil) as vlbil, 
 sum(cccf) as cccf,
 nfaturabsp,
 SUBSTRING(
 (SELECT GROUP_CONCAT(DISTINCT nrcarta) 
  FROM bspfatura b 
  WHERE
   b.dtbsp = :dtbsp        AND
   b.cia   = bspfatura.cia AND 
   b.nfaturabsp = bspfatura.nfaturabsp
  GROUP BY b.cia ),1,50 ) as nrcarta
FROM
 bspfatura
where 
 dtbsp = :dtbsp  
group by
 cia
The code is calling this querie is:

Code: Select all

 Qsoma.Close;
 Qsoma.ParamByName('dtbsp').Value :=FormatDateTime('yyyy-mm-dd',StrToDate(CBbsp.Items.Strings[CBbsp.ItemIndex])) ;
 Qsoma.Execute;

It only happens in this new version, using 5.20.1.14 this code works fine.

Why? How do I fix it?

Posted: Fri 25 Apr 2008 12:08
by Dimon
We can not reproduce the problem.
Please provide more information about your project. Do you use master/detail relationship between tables?

Posted: Fri 25 Apr 2008 15:52
by Wilton
Hi Dimon,

Answering your question, i don't use master/detail relationship. All tables used in the querie and subqueries don't haven relationship.

The Data Type of parameter :dtbsp is String and Param Type is IN.

Using the debugger to monitor this querie all occurrence of :dtbsp
is changed for one string looks like '2008-04-02', but when procedure Execute runs, the error its happens.

Posted: Sat 26 Apr 2008 10:11
by Dimon
We could not reproduce the problem.
Please send a complete small sample to dmitryg*crlab*com to demonstrate it, including a script to create and fill table.