Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-object-util.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-object-util.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-object-util.sql	11 Dec 2003 21:39:52 -0000	1.4
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-object-util.sql	7 Jul 2011 10:46:02 -0000	1.5
@@ -1,86 +1,131 @@
 -- moved from site-wide search to acs-kernel
 
-create or replace function acs_object_util__object_type_exist_p (varchar)
-returns boolean as '
-declare
-    p_object_type       alias for $1;
-    v_exist_p           boolean := ''t'';
-begin
 
 
-    select (case when count(*)=1 then ''t'' else ''f'' end) into v_exist_p
+-- added
+select define_function_args('acs_object_util__object_type_exist_p','object_type');
+
+--
+-- procedure acs_object_util__object_type_exist_p/1
+--
+CREATE OR REPLACE FUNCTION acs_object_util__object_type_exist_p(
+   p_object_type varchar
+) RETURNS boolean AS $$
+DECLARE
+    v_exist_p           boolean := 't';
+BEGIN
+
+
+    select (case when count(*)=1 then 't' else 'f' end) into v_exist_p
     from   acs_object_types 
     where  object_type = p_object_type;
  
     return v_exist_p;
-end;' language 'plpgsql' stable;
+END;
+$$ LANGUAGE plpgsql stable;
 
 
-create or replace function acs_object_util__get_object_type (integer)
-returns varchar as '
-declare
-    p_object_id         alias for $1;
+
+
+-- added
+select define_function_args('acs_object_util__get_object_type','object_id');
+
+--
+-- procedure acs_object_util__get_object_type/1
+--
+CREATE OR REPLACE FUNCTION acs_object_util__get_object_type(
+   p_object_id integer
+) RETURNS varchar AS $$
+DECLARE
     v_object_type       varchar(100);
-begin
+BEGIN
     select object_type into v_object_type
     from acs_objects
     where object_id = p_object_id;
 
     if not found then
-        raise exception ''acs_object_util__get_object_type: Invalid Object id: % '', p_object_id;
+        raise exception 'acs_object_util__get_object_type: Invalid Object id: % ', p_object_id;
     end if;
 
     return v_object_type;
 
-end;' language 'plpgsql' stable;
+END;
+$$ LANGUAGE plpgsql stable;
 
 
-create or replace function acs_object_util__type_ancestor_type_p (varchar,varchar)
-returns boolean as '
-declare
-    p_object_type1      alias for $1;
-    p_object_type2      alias for $2;
-begin
 
+
+-- added
+select define_function_args('acs_object_util__type_ancestor_type_p','object_type1,object_type2');
+
+--
+-- procedure acs_object_util__type_ancestor_type_p/2
+--
+CREATE OR REPLACE FUNCTION acs_object_util__type_ancestor_type_p(
+   p_object_type1 varchar,
+   p_object_type2 varchar
+) RETURNS boolean AS $$
+DECLARE
+BEGIN
+
     if not acs_object_util__object_type_exist_p(p_object_type1) then
-        raise exception ''Object type % does not exist'', p_object_type1;
+        raise exception 'Object type % does not exist', p_object_type1;
     end if;
 
     if not acs_object_util__object_type_exist_p(p_object_type2) then
-        raise exception ''Object type % does not exist'', p_object_type2;
+        raise exception 'Object type % does not exist', p_object_type2;
     end if;
         
     return exists (select 1
                    from acs_object_types o1, acs_object_types o2
                    where p_object_type2 = o2.object_type
                      and o1.object_type = p_object_type1
                      and o1.tree_sortkey between o2.tree_sortkey and tree_right(o2.tree_sortkey));
-end;' language 'plpgsql' stable;
+END;
+$$ LANGUAGE plpgsql stable;
 
 
 
-create or replace function acs_object_util__object_ancestor_type_p (integer,varchar)
-returns boolean as '
-declare
-    p_object_id         alias for $1;
-    p_object_type       alias for $2;
-    v_exist_p           boolean := ''f'';
+
+
+-- added
+select define_function_args('acs_object_util__object_ancestor_type_p','object_id,object_type');
+
+--
+-- procedure acs_object_util__object_ancestor_type_p/2
+--
+CREATE OR REPLACE FUNCTION acs_object_util__object_ancestor_type_p(
+   p_object_id integer,
+   p_object_type varchar
+) RETURNS boolean AS $$
+DECLARE
+    v_exist_p           boolean := 'f';
     v_object_type       varchar(100);
-begin
+BEGIN
     v_object_type := acs_object_util__get_object_type (p_object_id);
 
     v_exist_p := acs_object_util__type_ancestor_type_p (v_object_type, p_object_type);
     return v_exist_p;
-end;' language 'plpgsql' stable;
+END;
+$$ LANGUAGE plpgsql stable;
 
 
-create or replace function acs_object_util__object_type_p (integer,varchar)
-returns boolean as '
-declare
-    p_object_id         alias for $1;
-    p_object_type       alias for $2;
-    v_exist_p           boolean := ''f'';
-begin
+
+
+-- added
+select define_function_args('acs_object_util__object_type_p','object_id,object_type');
+
+--
+-- procedure acs_object_util__object_type_p/2
+--
+CREATE OR REPLACE FUNCTION acs_object_util__object_type_p(
+   p_object_id integer,
+   p_object_type varchar
+) RETURNS boolean AS $$
+DECLARE
+    v_exist_p           boolean := 'f';
+BEGIN
     v_exist_p := acs_object_util__object_ancestor_type_p(p_object_id, p_object_type);
     return v_exist_p;
-end;' language 'plpgsql' stable;
+END;
+$$ LANGUAGE plpgsql stable;
