pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
hiding column values for specific rows
3+ messages / 3 participants
[nested] [flat]

* hiding column values for specific rows
@ 2006-11-13 13:11 Luca Ferrari <fluca1978@infinito.it>
  2006-11-13 13:22 ` Re: hiding column values for specific rows A. Kretschmer <andreas.kretschmer@schollglas.com>
  2006-11-14 18:43 ` Re: hiding column values for specific rows Bricklen Anderson <banderson@presinet.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Luca Ferrari @ 2006-11-13 13:11 UTC (permalink / raw)
  To: pgsql-sql

Hi,
I don't know if this's possible but I'd like to hide column values for 
specific rows within a query. Imagine I've got a table with columns username 
and password: users(username,password). Now I'd like the user registered in 
the table to see her password, to see who is registered but not to see the 
other people passwords. For example, if the table contains:
username  | password
--------------+-------------
luca            | myPaswd
roberto       | otherPaswd
gianna        | thirdPaswd

I'd like to do a query like: "SELECT * FROM users where username=luca" 
obtaining something like:
username  | password
--------------+-------------
luca            | myPaswd
roberto       | xxxxx
gianna        | XXXXX

Is it possible to specify in the above query that all password columns that do 
not belong to selected row (username=luca) must be hidden? Anyone has an idea 
about how to implement this on the database side?

Thanks,
Luca



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: hiding column values for specific rows
  2006-11-13 13:11 hiding column values for specific rows Luca Ferrari <fluca1978@infinito.it>
@ 2006-11-13 13:22 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
  1 sibling, 0 replies; 3+ messages in thread

From: A. Kretschmer @ 2006-11-13 13:22 UTC (permalink / raw)
  To: pgsql-sql

am  Mon, dem 13.11.2006, um 14:11:50 +0100 mailte Luca Ferrari folgendes:
> Hi,
> I don't know if this's possible but I'd like to hide column values for 
> specific rows within a query. Imagine I've got a table with columns username 
> and password: users(username,password). Now I'd like the user registered in 
> the table to see her password, to see who is registered but not to see the 
> other people passwords. For example, if the table contains:
> username  | password
> --------------+-------------
> luca            | myPaswd
> roberto       | otherPaswd
> gianna        | thirdPaswd
> 
> I'd like to do a query like: "SELECT * FROM users where username=luca" 
> obtaining something like:
> username  | password
> --------------+-------------
> luca            | myPaswd
> roberto       | xxxxx
> gianna        | XXXXX
> 
> Is it possible to specify in the above query that all password columns that do 

You can do this with a VIEW and remoke all from normal users for the
original table. Within the VIEW, you can use current_user for the
username and/or a case when ... statement for the password-column.


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47215,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: hiding column values for specific rows
  2006-11-13 13:11 hiding column values for specific rows Luca Ferrari <fluca1978@infinito.it>
@ 2006-11-14 18:43 ` Bricklen Anderson <banderson@presinet.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Bricklen Anderson @ 2006-11-14 18:43 UTC (permalink / raw)
  To: Luca Ferrari <fluca1978@infinito.it>; +Cc: pgsql-sql

Luca Ferrari wrote:
> Hi,
> I don't know if this's possible but I'd like to hide column values for 
> specific rows within a query. Imagine I've got a table with columns username 
> and password: users(username,password). Now I'd like the user registered in 
> the table to see her password, to see who is registered but not to see the 
> other people passwords. For example, if the table contains:
> username  | password
> --------------+-------------
> luca            | myPaswd
> roberto       | otherPaswd
> gianna        | thirdPaswd
> 
> I'd like to do a query like: "SELECT * FROM users where username=luca" 
> obtaining something like:
> username  | password
> --------------+-------------
> luca            | myPaswd
> roberto       | xxxxx
> gianna        | XXXXX
> 
> Is it possible to specify in the above query that all password columns that do 
> not belong to selected row (username=luca) must be hidden? Anyone has an idea 
> about how to implement this on the database side?
> 
> Thanks,
> Luca
> 
You could try:
select username,case when username='luca' then password else 'XXXXXX' 
end as password from users;

Note that the the username 'luca' corresponds to the user querying the 
table.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-11-14 18:43 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-13 13:11 hiding column values for specific rows Luca Ferrari <fluca1978@infinito.it>
2006-11-13 13:22 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
2006-11-14 18:43 ` Bricklen Anderson <banderson@presinet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox