
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_PURAPTATTACH') 
 CREATE TABLE T_SRC_PURAPTATTACH (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPAPTATTACH') 
 CREATE TABLE T_SRC_SUPAPTATTACH (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SUPPLIERPICK' AND KSQL_COL_NAME ='FISBYMASTERID') 
 ALTER TABLE T_SRC_SUPPLIERPICK ADD (FISBYMASTERID CHAR(1) DEFAULT '0' NOT NULL );