Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 09 Aug 2004 @ 06:27:47 GMT


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


Subj:   Re: Using a parameter in a macro
 
From:   teradatanewsgroup

I missed some ':'

This works as requested:

     create macro sel_age
     (
         c_o varchar(2),
         c_age integer
     ) as (
     ABORT 'Wrong comparison operator has to be =, >, <, >= or <='
         WHERE :c_o not in ('=','>','<','>=','<=');

     select     *
     from     Table_with_age
     where (case
                         when :c_o = '=' then
                                 case when age = :c_age then 1 else 0 end
                         when :c_o = '<' then
                                 case when age < :c_age then 1 else 0 end
                         when :c_o = '>' then
                                 case when age > :c_age then 1 else 0 end
                         when :c_o = '>=' then
                                 case when age >= :c_age then 1 else 0 end
                         when :c_o = '<=' then
                                 case when age <= :c_age then 1 else 0 end
                         else 0
                 end) = 1
     ;
     order by age
     );

Ulrich

--
Ulrich Arndt



     
  <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