Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 27 Nov 2003 @ 10:24:55 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Inconsistent behaviour of 'Coalesce' function in VB application
 
From:   Agarwal, Rishi

Hi,

I am working on a VB application that is connecting with Teradata database using Teradata ODBC driver. In this application, I am using 'coalesce' function in a query and displaying the result in a grid. The problem is that, coalesce is working fine for simple case but not when some expression is used in it. When I run the same query in Queryman, results are being displayed correctly.

The query is as follows:

(Query string)
buildSQL = "Select coalesce(" & dataTable &
".timestamp_col1,(cast('1969-12-31 17:00:00' as TIMESTAMP(3)))) as
Column1, " & _
                 " (coalesce(" & dataTable & ".col2,0))/1000  as
column2, coalesce(" & dataTable & ".col3,0) as column3 from " &
dataTable

SQL looks like:

Select
        coalesce(table1.timestamp_col1,(cast('1969-12-31 17:00:00' as
TIMESTAMP(3)))) as Column1,
        (coalesce (table1.col2,0))/1000 as column2,
        coalesce(table1.col3,0) as column3
from
        table1

When I run the same sql in Queryman, coalesce works fine for all the three columns but in VB application coalesce is working only for column3. For other two columns(column1 & column2) null values are still being displayed as null.

Please let me know if there is some problem with coalesce function when used through ODBC. What should be the alternative for coalescei in that case. I tried using case-when also. But it is also behaving the same way.


Regards

Rishi Agarwal



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023