IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LIC_MODULE') 
 CREATE TABLE T_LIC_MODULE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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

 EXEC P_ALTERPK 'PK_T_LIC_MODULE', 'T_LIC_MODULE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LIC_MODULE_NUMBER') CREATE INDEX IDX_T_LIC_MODULE_NUMBER ON T_LIC_MODULE ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_LIC_MODULE_L', 'T_LIC_MODULE_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LIC_MODULE_L_FID') CREATE INDEX IDX_T_LIC_MODULE_L_FID ON T_LIC_MODULE_L ( FID ,FLOCALEID );

 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LIC_LICENSEGROUPAPPS') 
 CREATE TABLE T_LIC_LICENSEGROUPAPPS (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FMODULEID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_LIC_LICENSEGROUPAPPS' AND KSQL_COL_NAME ='FMODULEID') 
 ALTER TABLE T_LIC_LICENSEGROUPAPPS ADD (FMODULEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LIC_LICGROUPAPPS_TRIAL')
 CREATE TABLE T_LIC_LICGROUPAPPS_TRIAL (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FMODULEID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_LIC_LICGROUPAPPS_TRIAL' AND KSQL_COL_NAME ='FMODULEID')
 ALTER TABLE T_LIC_LICGROUPAPPS_TRIAL ADD (FMODULEID BIGINT DEFAULT 0 NOT NULL );

 