|  |  | Archives of the TeradataForumMessage Posted: Mon, 28 Apr 2003 @ 13:25:37 GMT
 
 
  
| Subj: |  | Re: Idea for the implementation of a view needed |  |  |  | From: |  | Geoffrey Rommel |  
 |  | The problem is to create a quick view, that supply rows from the table member_activity, but doesn't show customer_id for customers
from the table customer_restricted. |  | 
 
 
 
 Could you possibly use a macro instead of a view? For instance: 
REPLACE MACRO member_activity_restricted
 (in_cust_id    /* your data type here */ )
AS
(SELECT
 a.activity,
 CASE WHEN b.cust_id IS NOT NULL THEN 0 ELSE a.cust_id END cust_id
FROM
member_activity a
LEFT JOIN
customer_restricted b
ON a.cust_id = b.cust_id
WHERE a.cust_id = :in_cust_id ;)
;
 This only works for one customer ID, of course, but it would probably perform a nested join, which would be very fast, and it would
return all rows for that customer. Also, if you execute this a lot, the plastic steps would be cached. 
 
 |  |