/* $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_PLAN_ENROLLMENTS
 ( perf_plan_enrollment_id number             NOT NULL
  ,perf_plan_id            number             NOT NULL
  ,person_id               number             NOT NULL
  ,assignment_id           number             NOT NULL
  ,title                   varchar2(400 char) NOT NULL
  ,creator_type            varchar2(30)       NOT NULL
  ,status_code             varchar2(30)       NOT NULL
  ,start_date              date               NOT NULL
  ,end_date                date               NOT NULL
  ,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
  ,goal_setting_status_code varchar2(30)   DEFAULT ''N'' NOT NULL 
  ,attribute_category      varchar2(30)
  ,attribute1              varchar2(4000)
  ,attribute2              varchar2(4000)
  ,attribute3              varchar2(4000)
  ,attribute4              varchar2(4000)
  ,attribute5              varchar2(4000)
  ,attribute6              varchar2(4000)
  ,attribute7              varchar2(4000)
  ,attribute8              varchar2(4000)
  ,attribute9              varchar2(4000)
  ,attribute10             varchar2(4000)
  ,attribute11             varchar2(4000)
  ,attribute12             varchar2(4000)
  ,attribute13             varchar2(4000)
  ,attribute14             varchar2(4000)
  ,attribute15             varchar2(4000)
  ,attribute16             varchar2(4000)
  ,attribute17             varchar2(4000)
  ,attribute18             varchar2(4000)
  ,attribute19             varchar2(4000)
  ,attribute20             varchar2(4000)
  ,attribute21             varchar2(4000)
  ,attribute22             varchar2(4000)
  ,attribute23             varchar2(4000)
  ,attribute24             varchar2(4000)
  ,attribute25             varchar2(4000)
  ,attribute26             varchar2(4000)
  ,attribute27             varchar2(4000)
  ,attribute28             varchar2(4000)
  ,attribute29             varchar2(4000)
  ,attribute30             varchar2(4000))';
  
EXECUTE IMMEDIATE 'GRANT ALL ON XXAS_PERF_PLAN_ENROLLMENTS TO &1 WITH GRANT OPTION';

EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -955 THEN
 EXECUTE IMMEDIATE 'ALTER TABLE XXAS_PERF_PLAN_ENROLLMENTS
  ADD (
  goal_setting_status_code varchar2(30)   DEFAULT ''N'' NOT NULL 
  ,attribute_category      varchar2(30)
  ,attribute1              varchar2(4000)
  ,attribute2              varchar2(4000)
  ,attribute3              varchar2(4000)
  ,attribute4              varchar2(4000)
  ,attribute5              varchar2(4000)
  ,attribute6              varchar2(4000)
  ,attribute7              varchar2(4000)
  ,attribute8              varchar2(4000)
  ,attribute9              varchar2(4000)
  ,attribute10             varchar2(4000)
  ,attribute11             varchar2(4000)
  ,attribute12             varchar2(4000)
  ,attribute13             varchar2(4000)
  ,attribute14             varchar2(4000)
  ,attribute15             varchar2(4000)
  ,attribute16             varchar2(4000)
  ,attribute17             varchar2(4000)
  ,attribute18             varchar2(4000)
  ,attribute19             varchar2(4000)
  ,attribute20             varchar2(4000)
  ,attribute21             varchar2(4000)
  ,attribute22             varchar2(4000)
  ,attribute23             varchar2(4000)
  ,attribute24             varchar2(4000)
  ,attribute25             varchar2(4000)
  ,attribute26             varchar2(4000)
  ,attribute27             varchar2(4000)
  ,attribute28             varchar2(4000)
  ,attribute29             varchar2(4000)
  ,attribute30             varchar2(4000)
      )';
END IF;      
END;

/

COMMIT; 
EXIT;
