Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql,v
diff -u -r1.33.2.5 -r1.33.2.6
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql	12 Jan 2005 13:22:15 -0000	1.33.2.5
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql	14 Jan 2005 03:14:45 -0000	1.33.2.6
@@ -229,13 +229,12 @@
 
   end if;
 
-  return null; 
+  return v_folder_id; 
 end;' language 'plpgsql';
 
 -- procedure delete
-select define_function_args('content_folder__delete','folder_id,cascade_p;f');
-
-create or replace function content_folder__delete (integer, boolean)
+select define_function_args('content_folder__del','folder_id,cascade_p;f');
+create or replace function content_folder__del (integer, boolean)
 returns integer as '
 declare
   delete__folder_id              alias for $1;  
@@ -298,7 +297,19 @@
   return 0; 
 end;' language 'plpgsql';
 
+select define_function_args('content_folder__delete','folder_id,cascade_p;f');
 
+create or replace function content_folder__delete (integer, boolean)
+returns integer as '
+declare
+  delete__folder_id              alias for $1;  
+  p_cascade_p                    alias for $2;
+begin
+        PERFORM content_folder__del(delete__folder_id,p_cascade_p);
+  return 0; 
+end;' language 'plpgsql';
+
+
 create or replace function content_folder__delete (integer)
 returns integer as '
 declare
@@ -307,7 +318,7 @@
   v_parent_id                    integer;  
   v_path                         varchar;     
 begin
-	return content_folder__delete(
+	return content_folder__del(
 		delete__folder_id,
 		''f''
 		);
@@ -611,6 +622,8 @@
   LOOP
     v_parent_id := v_rec.parent_id;
     exit when v_parent_id = is_sub_folder__folder_id;
+    -- we did not find the folder, reset v_parent_id
+    v_parent_id := 0;
   end LOOP;
 
   if v_parent_id != 0 then 
