/**Begin D:\PDM_UPGRADE\PDM1\HBSS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPITEMACTENTRY' AND KSQL_COL_NAME ='FENTRYBOID') 
 ALTER TABLE T_HBSS_CAPITEMACTENTRY ADD (FENTRYBOID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPITEMRANKENTRY' AND KSQL_COL_NAME ='FENTRYBOID') 
 ALTER TABLE T_HBSS_CAPITEMRANKENTRY ADD (FENTRYBOID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FISMODIFY') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FISMODIFY CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FHISVERSION') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FHISVERSION VARCHAR(20) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FDATASTATUS') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FDATASTATUS VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FSOURCEVID') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FSOURCEVID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FCHANGEDESCRIPTION') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FCHANGEDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FISCURRENTVERSION') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FISCURRENTVERSION CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM' AND KSQL_COL_NAME ='FBOID') 
 ALTER TABLE T_HBSS_CAPACITYITEM ADD (FBOID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_CAPACITYITEM_L' AND KSQL_COL_NAME ='FCHANGEDESCRIPTION') 
 ALTER TABLE T_HBSS_CAPACITYITEM_L ADD (FCHANGEDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HBSS_SUBCAPITEMACT') 
 CREATE TABLE T_HBSS_SUBCAPITEMACT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUBCAPACTIONID BIGINT DEFAULT 0 NOT NULL,
FSUBKEYPOINT NVARCHAR(500) DEFAULT ' ' NOT NULL,
FSUBINDEX BIGINT DEFAULT 0 NOT NULL,
FENTRYBOID BIGINT DEFAULT 0 NOT NULL
);

/**End D:\PDM_UPGRADE\PDM1\HBSS_table.sql **/



/**Begin D:\PDM_UPGRADE\PDM1\HBSS_constraint.sql **/
 EXEC P_ALTERPK 'PK_HBSS_SUBCAPITEMACT', 'T_HBSS_SUBCAPITEMACT', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HBSS_SUBCAPITEMACT') CREATE INDEX IDX_HBSS_SUBCAPITEMACT ON T_HBSS_SUBCAPITEMACT ( FENTRYID );


 EXEC P_ALTERPK 'PK_HBSS_SUBCAPITEMACT_L', 'T_HBSS_SUBCAPITEMACT_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HBSS_SUBCAPITEMACT_L') CREATE INDEX IDX_HBSS_SUBCAPITEMACT_L ON T_HBSS_SUBCAPITEMACT_L ( FDETAILID ,FLOCALEID );

/**End D:\PDM_UPGRADE\PDM1\HBSS_constraint.sql **/
