If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Views - with a twist

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-27-06, 08:37
Keith Cunningha Keith Cunningha is offline
Registered User
 
Join Date: Mar 2004
Location: USA
Posts: 4
Question Views - with a twist

I need to construct a view so that a certain field from the underlying table will not display any values BUT I can still enter selection criteria agasint that field in the Where clause of an SQL running against that view.

Your assistance will be greatly appreciated.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 07-27-06, 08:40
Keith Cunningha Keith Cunningha is offline
Registered User
 
Join Date: Mar 2004
Location: USA
Posts: 4
Sorry - forgot my version

I am using DB2 V8.1 on a UNIX AIX server
Reply With Quote
  #3 (permalink)  
Old 07-28-06, 03:40
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
just a guess.. plz check it out

suppose view V(c1) is crerated from table T( c1, c2):
select * from v where c1 in (select c1 from T where c2 like < > );
but u have to take care rthat c1 and c2 both are having unique values.

Rahul
Reply With Quote
  #4 (permalink)  
Old 07-28-06, 08:50
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Quote:
Originally Posted by Keith Cunningha
I need to construct a view so that a certain field from the underlying table will not display any values BUT I can still enter selection criteria agasint that field in the Where clause of an SQL running against that view.
So you want to create a view that has READ permission on one of its columns, as the user must be able to use it in its WHERE clause and that same column must have NO READ permission because its contents may not be made visual. Hmmm, sounds like a real contradictio in terms. Can you explain a bit more about this requirement ? How will this view be used and its results displayed ?

Suppose the rule is: you may only show the managers who make less than USD 1,000,000 a year:
You could write
CREATE VIEW V (nr_emp, name)
FROM employee
WHERE salary < 1000000;

So in a sense you used the 'secret' column salary, but it doesn't show in the view, but this is not what you want.

You could write a stored procedure that accepts the value for the secret column and make it return a table without the secret column, but you would lose the felxibility of a true WHERE clause (>, >=, = , <, between, ...) you would have to write multiple SP's top handle them all or one (very) flexible one that can handle all those possibilities.

Please can you elaborate a bit more on this constraint and use of the view?
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On