Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql,v
diff -u -r1.10 -r1.11
--- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql	15 May 2001 05:09:08 -0000	1.10
+++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql	16 May 2001 00:40:41 -0000	1.11
@@ -954,6 +954,7 @@
                 quote_literal(evaluate_guard__place_key) || '','' || 
                 quote_literal(evaluate_guard__direction) || '','' || 
                 coalesce(quote_literal(evaluate_guard__custom_arg),''null'') || '') as guard_happy_p'';
+                raise notice ''str = %'', v_str;
                 for v_rec in 
                     execute v_str
                 LOOP
@@ -975,12 +976,14 @@
   execute_transition_callback__custom_arg             alias for $2;  
   execute_transition_callback__case_id                alias for $3;  
   execute_transition_callback__transition_key         alias for $4;  
+  v_str                                               text;
 begin
         if execute_transition_callback__callback != '''' and execute_transition_callback__callback is not null then 
-            execute ''select '' || execute_transition_callback__callback
+            v_str := ''select '' || execute_transition_callback__callback
             || ''('' || execute_transition_callback__case_id || '','' || 
             quote_literal(execute_transition_callback__transition_key) || '','' || 
-            quote_literal(execute_transition_callback__custom_arg) || '')'';
+            coalesce(quote_literal(execute_transition_callback__custom_arg),''null'') || '')'';
+            execute v_str;
         end if;
 
         return 0; 
@@ -996,15 +999,18 @@
   execute_time_callback__case_id                alias for $3;  
   execute_time_callback__transition_key         alias for $4;  
   v_rec                                         record;
+  v_str                                         text;
 begin
         if execute_time_callback__callback = '''' or execute_time_callback__callback is null then
             raise EXCEPTION ''-20000: There''''s no time_callback function for the timed transition "%"'', execute_time_callback__transition_key;
         end if;
  
-        for v_rec in execute ''select '' || execute_time_callback__callback || ''('' || 
-                  execute_time_callback__case_id || '','' || 
-                  quote_literal(execute_time_callback__transition_key) || '','' || 
-                  quote_literal(execute_time_callback__custom_arg) || '') as trigger_time''
+        v_str := ''select '' || execute_time_callback__callback || ''('' || 
+                 execute_time_callback__case_id || '','' || 
+                 quote_literal(execute_time_callback__transition_key) || '','' || 
+                 coalesce(quote_literal(execute_time_callback__custom_arg),''null'') || '') as trigger_time''
+
+        for v_rec in execute v_str
         LOOP
             return v_rec.trigger_time;
         end LOOP;
@@ -1043,9 +1049,10 @@
             if get_task_deadline__callback != '''' and get_task_deadline__callback is not null then
                 /* callback */
                 v_str := ''select '' || get_task_deadline__callback || ''('' || 
-                get_task_deadline__case_id || '','' || 
-                quote_literal(get_task_deadline__transition_key) || '','' || 
-                quote_literal(get_task_deadline__custom_arg) || '') as deadline'';
+                         get_task_deadline__case_id || '','' || 
+                         quote_literal(get_task_deadline__transition_key) || '','' || 
+                         coalesce(quote_literal(get_task_deadline__custom_arg),''null'') || '') as deadline'';
+
                 for v_rec in execute v_str
                 LOOP
                     v_deadline := v_rec.deadline;
@@ -1077,17 +1084,20 @@
   execute_hold_timeout_callback__transition_key         alias for $4;  
   v_hold_timeout                                        timestamp;
   v_rec                                                 record;
+  v_str                                                 text;
 begin
         if execute_hold_timeout_callback__callback = '''' or execute_hold_timeout_callback__callback is null then
             return null;
         end if;
  
-        for v_rec in 
-        execute ''select '' || execute_hold_timeout_callback__callback 
-        || ''('' ||
-        execute_hold_timeout_callback__case_id || '','' ||
-        quote_literal(execute_hold_timeout_callback__transition_key) || '','' ||
-        quote_literal(execute_hold_timeout_callback__custom_arg) || '') as hold_timeout''
+        v_str := ''select '' || execute_hold_timeout_callback__callback 
+              || ''('' ||
+              execute_hold_timeout_callback__case_id || '','' ||
+              quote_literal(execute_hold_timeout_callback__transition_key) || 
+              '','' ||
+              coalesce(quote_literal(execute_hold_timeout_callback__custom_arg),''null'') || '') as hold_timeout'';
+
+        for v_rec in execute v_str
         LOOP
            return v_rec.hold_timeout;
         end LOOP;
@@ -1103,11 +1113,16 @@
 declare
   callback               alias for $1;  
   task_id                alias for $2;  
-  custom_arg             alias for $3;  
+  custom_arg             alias for $3; 
+  v_str                  text; 
 begin
         if callback != '''' and callback is not null then
-            execute ''select '' || callback
-            || ''('' || task_id || '','' || quote_literal(custom_arg) || '')'';
+            v_str := ''select '' || callback
+                     || ''('' || task_id || '','' || 
+                     coalesce(quote_literal(custom_arg),''null'') 
+                     || '')'';
+
+            execute v_str;
         end if;
 
         return 0; 
@@ -1154,7 +1169,7 @@
             if set_task_assignments__callback != '''' and set_task_assignments__callback is not null then
                 execute ''select ''|| set_task_assignments__callback || ''('' || 
                 set_task_assignments__task_id || '','' || 
-                quote_literal(set_task_assignments__custom_arg) || '')'';
+                coalesce(quote_literal(set_task_assignments__custom_arg),''null'') || '')'';
             else
                 for context_assignment_rec in  
                     select party_id
@@ -1581,13 +1596,14 @@
 
         if notify_assignee__callback != '''' and notify_assignee__callback is not null then
             v_str :=  ''select '' || notify_assignee__callback || ''('' || 
-            notify_assignee__task_id || '','' ||
-            coalesce(quote_literal(notify_assignee__custom_arg),''null'') || 
-            '','' ||
-            notify_assignee__user_id || '','' ||
-            v_party_from || '','' ||
-            quote_literal(v_subject) || '','' ||
-            quote_literal(v_body) || '')'';
+                      notify_assignee__task_id || '','' ||
+                      coalesce(quote_literal(notify_assignee__custom_arg),''null'') || 
+                      '','' ||
+                      notify_assignee__user_id || '','' ||
+                      v_party_from || '','' ||
+                      quote_literal(v_subject) || '','' ||
+                      quote_literal(v_body) || '')'';
+
             execute v_str;
         end if;
             
