changeset 172:e9f9c72bfa48

create view "gecoses", through which gecos name can be retrieved
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 19 Feb 2016 15:36:51 +0859
parents cdade692e17d
children 31e63d173d38
files s4-init.sh
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/s4-init.sh	Thu Feb 11 17:06:19 2016 +0859
+++ b/s4-init.sh	Fri Feb 19 15:36:51 2016 +0859
@@ -75,6 +75,18 @@
 	primary key(user, tbl, rowid), \
 	foreign key(user) references user(name))"
 
+create view gecoses "AS
+SELECT name,
+       coalesce(
+         case when (SELECT name FROM user u WHERE u.name=name) IS NOT NULL
+	      then (SELECT val FROM user_s u
+	            WHERE u.name=a.name AND key='gecos')
+	      else (SELECT val FROM grp_s g
+	      	    WHERE g.gname=name AND key='gecos')
+	 end,
+	 name) gecos
+FROM (SELECT name FROM user UNION ALL SELECT gname FROM grp) a;"
+
 
 for f in $formdir/*def; do
   echo -n Creating form of $f...

yatex.org