|
|
Archives of the TeradataForum
Message Posted: Fri, 30 Jul 2004 @ 14:48:47 GMT
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 (
SELECT
( 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;) ;
Victor
| |