View Single Post

   
  #2 (permalink)  
Old 02-27-2008, 03:06 AM
kenfar
 
Posts: n/a
Default Re: Newbie Query: Is this an appropriate place for a VIEW?

SteveInTallyFl wrote:
> My gut says a VIEW is the way to do this, but I dont know
> how to place null values into an element based on the flag
> test, and I dont want to make a 'more expensive' application
> for the user.


Well, assuming that this table isn't gigantic (600 gbytes, etc) then
i'd probably leave all the data in a single table and just use a view.

If you really need to have the view return nulls then I think this
could work for you:
CREATE VIEW non_confidential_v (
customer_id ,
purchase_date ,
product_name ,
quantity ,
purchase_price ) AS (
SELECT customer_id ,
purchase_date ,
CASE confidentiality_flag
WHEN 'Y' THEN NULL
ELSE product_name
END AS product_name ,
quantity ,
purchase_price )

ken

Reply With Quote