Home Page for the TeradataForum

Archives of the TeradataForum

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

  <Prev Next>  
Next> Last>>  

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


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 " &

SQL looks like:

        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

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.


Rishi Agarwal

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