IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_PERSONAL_PREFERENCES')
CREATE TABLE T_ER_PERSONAL_PREFERENCES (
   FID BIGINT DEFAULT 0 NOT NULL,
   FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
   FNAME VARCHAR(30) DEFAULT ' ' NOT NULL,
   FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
   FCREATORID BIGINT DEFAULT 0 NOT NULL,
   FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
   FCREATETIME DATETIME,
   FMODIFYTIME DATETIME,
   FMASTERID BIGINT DEFAULT 0 NOT NULL,
   FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
   FUSER BIGINT DEFAULT 0 NOT NULL,
   FORG BIGINT DEFAULT 0 NOT NULL,
   FCOMPANY BIGINT DEFAULT 0 NOT NULL,
   FPREFERENCES NVARCHAR(1000) DEFAULT ' ' NOT NULL
);
EXEC p_AlterPK 'PK_ER_PERSONAL_PREFERENCES', 'T_ER_PERSONAL_PREFERENCES', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_PERSONAL_PREFERENCES' AND KSQL_INDNAME = 'IDX_ER_PERSONAL_PREFERENCES')
CREATE INDEX IDX_ER_PERSONAL_PREFERENCES ON T_ER_PERSONAL_PREFERENCES (FUSER);


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

EXEC p_AlterPK 'PK_ER_PERSONAL_PREFERENCES_L', 'T_ER_PERSONAL_PREFERENCES_L', 'FPKID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_PERSONAL_PREFERENCES_L' AND KSQL_INDNAME = 'IDX_ER_PERSONAL_PREFERENCES_L')
CREATE INDEX IDX_ER_PERSONAL_PREFERENCES_L ON T_ER_PERSONAL_PREFERENCES_L (FID ,FLOCALEID);





