--
-- acs-workflow/sql/wf-callback-package.sql
--
-- Creates the PL/SQL package that provides a small library of reusable
-- workflow callback functions/procedures.
--
-- @author Lars Pind (lars@pinds.com)
--
-- @creation-date 2000-05-18
--
-- @cvs-id $Id: wf-callback-package.sql,v 1.4 2001/05/14 23:16:08 danw Exp $
--

-- create or replace package wf_callback
-- as
-- 
--     function guard_attribute_true(
--         case_id 	in integer,
-- 	workflow_key 	in varchar2,
-- 	transition_key 	in varchar2,
-- 	place_key 	in varchar2,
-- 	direction 	in varchar2,
-- 	custom_arg 	in varchar2
--     ) return char;
--     	
--     function time_sysdate_plus_x(
-- 	case_id 	in integer,
-- 	transition_key 	in varchar2,
-- 	custom_arg in varchar2
--     ) return date;
-- 
-- end wf_callback;

-- show errors

-- create or replace package body wf_callback
-- function guard_attribute_true
create function wf_callback__guard_attribute_true (integer,varchar,varchar,varchar,varchar,varchar)
returns boolean as '
declare
  guard_attribute_true__case_id         alias for $1;  
  guard_attribute_true__workflow_key    alias for $2;  
  guard_attribute_true__transition_key  alias for $3;  
  guard_attribute_true__place_key       alias for $4;  
  guard_attribute_true__direction       alias for $5;  
  guard_attribute_true__custom_arg      alias for $6;  
begin
        return workflow_case__get_attribute_value(
	    guard_attribute_true__case_id, 
	    guard_attribute_true__custom_arg
	);
     
end;' language 'plpgsql';


-- function time_sysdate_plus_x
create function wf_callback__time_sysdate_plus_x (integer,varchar,text)
returns timestamp as '
declare
  time_sysdate_plus_x__case_id          alias for $1;  
  time_sysdate_plus_x__transition_key   alias for $2;  
  time_sysdate_plus_x__custom_arg       alias for $3;  
begin
        return now() + (time_sysdate_plus_x__custom_arg || '' days'')::interval;
     
end;' language 'plpgsql';



-- show errors

