/**Begin C:\PDM_UPGRADE\PDM1\PBD_table.sql **/
 EXEC p_AlterColumn 'T_PBD_STRUCT_INPUTENTITY', 'FINPUTSFIELDID', 'VARCHAR(80)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PBD_STRUCT_INPUTENTITY', 'FINPUTSFIELDNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PBD_STRUCT_OUTPUTENTITY', 'FOUTPUTSFIELDID', 'VARCHAR(80)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PBD_STRUCT_OUTPUTENTITY', 'FOUTPUTSFIELDNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_SMONI_DATA' AND KSQL_COL_NAME IN ('FEID')) 
 ALTER TABLE T_PBD_SMONI_DATA ADD (FEID VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_MONITOR' AND KSQL_COL_NAME IN ('FGROUPID')) 
 ALTER TABLE T_PBD_MONITOR ADD (FGROUPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_MONITOR' AND KSQL_COL_NAME IN ('FGROUPIDSTR')) 
 ALTER TABLE T_PBD_MONITOR ADD (FGROUPIDSTR NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_MONITOR' AND KSQL_COL_NAME IN ('FISBINDURL')) 
 ALTER TABLE T_PBD_MONITOR ADD (FISBINDURL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_MONITOR' AND KSQL_COL_NAME IN ('FOPTTYPE')) 
 ALTER TABLE T_PBD_MONITOR ADD (FOPTTYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_MONITOR' AND KSQL_COL_NAME IN ('FMONITORTYPE')) 
 ALTER TABLE T_PBD_MONITOR ADD (FMONITORTYPE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_MONITOR' AND KSQL_COL_NAME IN ('FJOBID')) 
 ALTER TABLE T_PBD_MONITOR ADD (FJOBID VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_SMONI_BASICENTITY') 
 CREATE TABLE T_PBD_SMONI_BASICENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBASICINFOID BIGINT DEFAULT 0 NOT NULL,
FAPPROVEDTIME DATETIME,
FUPDATETIME DATETIME,
FOPERATINGPERIODFROM DATETIME,
FOPERATINGPERIODTO DATETIME,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLEGALPERSONNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBELONGORG NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCOMPANYORGTYPE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FREGSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREGCAPITAL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCURRENCYUNIT NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUSINESSSCOPE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBUSINESSSCOPE_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_MONITOR_GROUP_L') 
 CREATE TABLE T_PBD_MONITOR_GROUP_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_MONITOR_GROUPENTRY') 
 CREATE TABLE T_PBD_MONITOR_GROUPENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FAPIID VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXTSYSAPIID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_MONITOR_GROUP') 
 CREATE TABLE T_PBD_MONITOR_GROUP (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FISPRESET CHAR(1) DEFAULT ' ' NOT NULL,
FAPIIDS NVARCHAR(512) DEFAULT ' ' NOT NULL,
FGROUPIDSTR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPTTYPE CHAR(1) DEFAULT '1' NOT NULL,
FMONITORTYPE CHAR(1) DEFAULT '0' NOT NULL
);



/**End C:\PDM_UPGRADE\PDM1\PBD_table.sql **/
