User Tools

Site Tools


podoc:count_equipment_by_user_sql_function

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
podoc:count_equipment_by_user_sql_function [2007/04/23 14:25] Luudpodoc:count_equipment_by_user_sql_function [2007/10/19 16:08] (current) Luud
Line 18: Line 18:
  
 <code sql> <code sql>
-create function count_equipment_by_user(integer) returns bigint +create function count_equipment_by_user(integer) returns bigint as ' 
-as 'select ((select count(identifier) from lens where users = $1) ++        select ((select count(identifier) from lens where users = $1) +
             (select count(identifier) from camera where users = $1) +             (select count(identifier) from camera where users = $1) +
-            (select count(identifier) from flash where users = $1) + 
             (select count(identifier) from scanner where users = $1) +             (select count(identifier) from scanner where users = $1) +
             (select count(identifier) from film where users = $1) +             (select count(identifier) from film where users = $1) +
             (select count(identifier) from support where users = $1) +             (select count(identifier) from support where users = $1) +
-            (select count(identifier) from flash where users = $1))' language 'sql';+            (select count(identifier) from flash where users = $1)) 
 +' language 'sql';
 </code> </code>
  
 <code sql> <code sql>
-create function count_equipment_by_user(integer, integer) returns bigint +create function count_equipment_by_user(integer, integer) returns bigint as ' 
-as 'select ((select count(identifier) from lens where users = $1 and access_rights <= $2) ++        select ((select count(identifier) from lens where users = $1 and access_rights <= $2) +
             (select count(identifier) from camera where users = $1 and access_rights <= $2) +             (select count(identifier) from camera where users = $1 and access_rights <= $2) +
-            (select count(identifier) from flash where users = $1 and access_rights <= $2) + 
             (select count(identifier) from scanner where users = $1 and access_rights <= $2) +             (select count(identifier) from scanner where users = $1 and access_rights <= $2) +
             (select count(identifier) from film where users = $1 and access_rights <= $2) +             (select count(identifier) from film where users = $1 and access_rights <= $2) +
             (select count(identifier) from support where users = $1 and access_rights <= $2) +             (select count(identifier) from support where users = $1 and access_rights <= $2) +
-            (select count(identifier) from flash where users = $1 and access_rights <= $2))' language 'sql';+            (select count(identifier) from flash where users = $1 and access_rights <= $2)) 
 +' language 'sql';
 </code> </code>
  
Line 82: Line 82:
             (select count(identifier) from support where users = $1 and access_rights <= $2) +             (select count(identifier) from support where users = $1 and access_rights <= $2) +
             (select count(identifier) from flash where users = $1 and access_rights <= $2))' language 'sql';             (select count(identifier) from flash where users = $1 and access_rights <= $2))' language 'sql';
 +</code>
 +
 += Version 2.34 =
 +
 +<code sql>
 +---- Fix up a couple of bogus functions
 +create or replace function count_equipment_by_user(integer) returns bigint as '
 +        select ((select count(identifier) from lens where users = $1) +
 +            (select count(identifier) from camera where users = $1) +
 +            (select count(identifier) from scanner where users = $1) +
 +            (select count(identifier) from film where users = $1) +
 +            (select count(identifier) from support where users = $1) +
 +            (select count(identifier) from flash where users = $1))
 +' language 'sql';
 +
 +create or replace function count_equipment_by_user(integer, integer) returns bigint as '
 +        select ((select count(identifier) from lens where users = $1 and access_rights <= $2) +
 +            (select count(identifier) from camera where users = $1 and access_rights <= $2) +
 +            (select count(identifier) from scanner where users = $1 and access_rights <= $2) +
 +            (select count(identifier) from film where users = $1 and access_rights <= $2) +
 +            (select count(identifier) from support where users = $1 and access_rights <= $2) +
 +            (select count(identifier) from flash where users = $1 and access_rights <= $2))
 +' language 'sql';
 </code> </code>
  
podoc/count_equipment_by_user_sql_function.txt · Last modified: 2007/10/19 16:08 by Luud