/**Begin C:\PDM_UPGRADE\PDM1\PBD_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_CONTROLDIMENSION') 
 CREATE TABLE T_PBD_CONTROLDIMENSION (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FBASEDATATYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FFIELDNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FPLUGIN VARCHAR(255) DEFAULT ' ' NOT NULL,
FPLUGINPARAMS VARCHAR(255) DEFAULT ' ' NOT NULL,
FISSYS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_CONTROLDIMENSION_L') 
 CREATE TABLE T_PBD_CONTROLDIMENSION_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_BILLREGISTER') 
 CREATE TABLE T_PBD_BILLREGISTER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FBILLENTITYID VARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_BILLREGISTER_L') 
 CREATE TABLE T_PBD_BILLREGISTER_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_BILLREGISTENTRY') 
 CREATE TABLE T_PBD_BILLREGISTENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FBILLFIELD VARCHAR(255) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_CONTROLTYPE') 
 CREATE TABLE T_PBD_CONTROLTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(500) DEFAULT ' ' NOT NULL,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FINTERFACE VARCHAR(255) DEFAULT ' ' NOT NULL,
FPARAMPAGE VARCHAR(100) DEFAULT ' ' NOT NULL,
FDEFAULTCLASS VARCHAR(255) DEFAULT ' ' NOT NULL,
FCONTROLTYPE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_CONTROLTYPE_L') 
 CREATE TABLE T_PBD_CONTROLTYPE_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_DIMENSIONENTRY') 
 CREATE TABLE T_PBD_DIMENSIONENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_CONTROLDIMENSION' AND KSQL_COL_NAME IN ('FREMARK')) 
 ALTER TABLE T_PBD_CONTROLDIMENSION ADD (FREMARK NVARCHAR(255) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_BILLREGISTER' AND KSQL_COL_NAME IN ('FREMARK')) 
 ALTER TABLE T_PBD_BILLREGISTER ADD (FREMARK NVARCHAR(255) DEFAULT ' ' );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_CONTROLSCHEME') 
 CREATE TABLE T_PBD_CONTROLSCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FBILLENTITYID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(512) DEFAULT ' ' NOT NULL,
FOPERATIONFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTROLTYPEID BIGINT DEFAULT 0 NOT NULL,
FDEFAULTCLASS VARCHAR(255) DEFAULT ' ' NOT NULL,
FCONTROLMODE CHAR(1) DEFAULT ' ' NOT NULL,
FTOOLTIPS NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PBD_CONTROLSCHEME_L') 
 CREATE TABLE T_PBD_CONTROLSCHEME_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,
FTOOLTIPS NVARCHAR(512) DEFAULT ' ' NOT NULL
);
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_BILLREGISTER' AND KSQL_COL_NAME IN ('FISSYS')) 
 ALTER TABLE T_PBD_BILLREGISTER ADD (FISSYS CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_PBD_CONTROLSCHEME', 'FDESCRIPTION', 'NVARCHAR(512)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_CONTROLSCHEME' AND KSQL_COL_NAME IN ('FISSYS')) 
 ALTER TABLE T_PBD_CONTROLSCHEME ADD (FISSYS CHAR(1) DEFAULT '0' NOT NULL );
 
  EXEC p_AlterColumn 'T_PBD_CONTROLDIMENSION', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PBD_BILLREGISTER', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PBD_CONTROLTYPE', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PBD_CONTROLSCHEME', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_CONTROLSCHEME' AND KSQL_COL_NAME IN ('FFILTERPAGE')) 
 ALTER TABLE T_PBD_CONTROLSCHEME ADD (FFILTERPAGE NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_CONTROLSCHEME' AND KSQL_COL_NAME IN ('FFILTERGRIDTEXT_TAG')) 
 ALTER TABLE T_PBD_CONTROLSCHEME ADD (FFILTERGRIDTEXT_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PBD_CONTROLSCHEME' AND KSQL_COL_NAME IN ('FFILTERGRIDTEXT')) 
 ALTER TABLE T_PBD_CONTROLSCHEME ADD (FFILTERGRIDTEXT NCLOB );
 
 
/**End C:\PDM_UPGRADE\PDM1\PBD_table.sql **/
