Board index » delphi » ADO query - data type conversion

ADO query - data type conversion

I need to compare a number value to a string value in my query, however, to_char is not a valid function in delpi and cast() returns an empty data set.

         SQL.Add('SELECT PN, AVG(TIME1) AS AVGTIME, SUM(TIME1)   AS SUMTIME, COUNT(*) AS MYCOUNT ');
         SQL.Add('FROM (' );
         SQL.Add('SELECT PN, TIME1 ');
         SQL.Add('FROM [' + v_ScanFile + '] ');
         SQL.Add('WHERE SO IN (SELECT DISTINCT CAST(SO AS CHARACTER) ');
         SQL.Add('FROM [' + v_JobNumber + '] ');
         SQL.Add('WHERE ACTCOMP IS NOT NULL)');

 

Re:ADO query - data type conversion


Quote
>        SQL.Add('WHERE SO IN (SELECT DISTINCT CAST(SO AS CHARACTER) ');

You need to specify a character size with Cast
try something like

     SQL.Add('WHERE SO IN (SELECT DISTINCT CAST(SO AS CHAR(10)) ');
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads