IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_RECOMPLANORDER')
CREATE TABLE T_ER_RECOMPLANORDER (
                                     FID BIGINT DEFAULT 0 NOT NULL,
                                     FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                     FAGENTENTRYID BIGINT DEFAULT 0 NOT NULL,
                                     FORDERNUM VARCHAR(255) DEFAULT ' ' NOT NULL,
                                     FSEQ INT DEFAULT 0 NOT NULL
);

EXEC p_AlterPK 'PK_ER_RECOMPLANORDER', 'T_ER_RECOMPLANORDER', 'FENTRYID', '1';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_RECOMPLANORDER' AND KSQL_INDNAME = 'IDX_RECOMPLANORDER_FORDERNUM')
CREATE INDEX IDX_RECOMPLANORDER_FORDERNUM ON T_ER_RECOMPLANORDER (FORDERNUM );

