|
|
Archives of the TeradataForum
Message Posted: Mon, 09 Aug 2004 @ 06:27:47 GMT
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
| |