/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2008 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK
DECLARE 
BEGIN

EXECUTE IMMEDIATE 'CREATE TABLE xxas_perf_review_forms
  (perf_review_form_id     number         NOT NULL PRIMARY KEY
  ,perf_review_template_id number         NOT NULL
  ,perf_plan_enrollment_id number         NOT NULL
  ,person_id               number         NOT NULL
  ,assignment_id           number         NOT NULL
  ,start_date              date
  ,due_date                date
  ,status_code             varchar2(30)    NOT NULL
  ,creator_type            varchar2(1)    NOT NULL
  ,current_step_id         number
  ,current_step_person_id  number
  ,created_by              number         NOT NULL
  ,creation_date           date           NOT NULL
  ,last_update_date        date           NOT NULL
  ,last_updated_by         number         NOT NULL
  ,last_update_login       number         NOT NULL
  )';
  
EXECUTE IMMEDIATE 'GRANT ALL ON xxas_perf_review_forms TO &1 WITH GRANT OPTION';

EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -955 THEN
 EXECUTE IMMEDIATE 'ALTER TABLE xxas_perf_review_forms MODIFY (current_step_id NULL)';
END IF;      
END;
/  

COMMIT;
EXIT;