 |
 |
Archives of the TeradataForum
Message Posted: Sat, 07 Aug 2004 @ 10:01:55 GMT
Subj: | | Re: Using a parameter in a macro |
|
From: | | teradatanewsgroup |
Hi Srinivas,
I was not able to test the syntax as I have now no access to an DB but something like the following should work.
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
;
);
Kind regards
Ulrich
--
Ulrich Arndt
| |