--
-- workflow__new/8
--
create or replace function workflow__new(
  character varying,
  character varying,
  character varying,
  integer,
  character varying,
  integer,
  character varying,
  integer
) returns int4 as $$

declare
    p_short_name            alias for $1;
    p_pretty_name           alias for $2;
    p_package_key           alias for $3;
    p_object_id             alias for $4;
    p_object_type           alias for $5;
    p_creation_user         alias for $6;
    p_creation_ip           alias for $7;
    p_context_id            alias for $8;
  
    v_workflow_id           integer;
begin
    -- Instantiate the ACS Object super type with auditing info
    v_workflow_id  := acs_object__new(null,
                                      'workflow_lite',
                                      now(),
                                      p_creation_user,
                                      p_creation_ip,
                                      p_context_id,
                                      't');

    -- Insert workflow specific info into the workflows table
    insert into workflows
           (workflow_id, short_name, pretty_name, package_key, object_id, object_type)
       values
           (v_workflow_id, p_short_name, p_pretty_name, p_package_key, p_object_id, p_object_type);
            

   return v_workflow_id;
end;
$$ language plpgsql;