Robert Haas <robertmh...@gmail.com> wrote:
 
> What is the use case for the status quo?
 
Much simplified:

create table party
(
  countyno smallint not null,
  caseno varchar(14) not null,
  partyno smallint not null,
  name text not null,
  address text,
  isaddrsealed boolean not null,
  primary key (countyno, caseno, partyno)
);

create table sealedaddrauth
(
  userid text not null primary key
);

create view partyview as
  select countyno, caseno, partyno,
    case
      when isaddrsealed and not exists
       (select * from sealedaddrauth
        where userid = current_user)
      then '*** SEALED ***'
      else address
    end as address,
    isaddrsealed
  from party
;

insert into party values (1,'2010FA000123',1,'Jane Doe',
'123 Victim Ave., Anytown, WI 53599',true);
insert into party values (1,'2010FA000123',2,'John Doe',
'123 Stalker St., Hometown, WI 53666',false);
 
-- Kevin

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to