Index: openacs-4/packages/categories/sql/oracle/category-package.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/oracle/category-package.sql,v
diff -u -N -r1.4 -r1.4.16.1
--- openacs-4/packages/categories/sql/oracle/category-package.sql	6 Feb 2005 18:42:19 -0000	1.4
+++ openacs-4/packages/categories/sql/oracle/category-package.sql	17 Apr 2019 09:07:08 -0000	1.4.16.1
@@ -298,9 +298,9 @@
 	and left_ind > v_old_left_ind;
 
 	if (change_parent.parent_id is null) then
-	   select 1, max(right_ind)+1 into v_new_left_ind, v_new_right_ind
+	   select 1, coalesce(max(right_ind)+1, 1) into v_new_left_ind, v_new_right_ind
 	   from categories
-	   where tree_id = change_parent.tree_id;
+	   where tree_id = change_parent.tree_id and right_ind > 0;
 	else
 	   select left_ind, right_ind into v_new_left_ind, v_new_right_ind
 	   from categories
