Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Fri, 30 Jul 2004 @ 14:48:47 GMT

  <Prev Next>   <<First <Prev

Subj:   Re: Macros: Treating a parameter as an object
From:   Victor Sokovin

  I don't have time to check this out but I slight modified your code to concatenate all columns into one column using the value in the column specified and the empty string in all the other columns.  

The macro seems to work as expected. I just had to add parentheses around COALESCE:

     REPLACE MACRO MyMacro (colname char(30)) AS (
     ( CASE WHEN :colname = 'COL1' THEN (Coalesce(COL1,'')) ELSE '' END) ||
     ( CASE WHEN :colname = 'COL2' THEN (Coalesce(COL2,'')) ELSE '' END) ||
     ( CASE WHEN :colname = 'COL3' THEN (Coalesce(COL3,'')) ELSE '' END )
     FROM T1
     GROUP BY 1;) ;


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