Hello all,
I am working on a script which should parse a large file called input.txt which contains table definitions, index definitions and comments like these ones:
------------------------------------------------
-- DDL Statements for table "CMWSYS"."CMWD_TEC_SUIVI_TRT"
------------------------------------------------
CREATE TABLE "CMWSYS"."CMWD_TEC_SUIVI_TRT" (
"ORDER_ID" VARCHAR(20) ,
"PERIODE_DATE" VARCHAR(50) ,
"NOM_JOB" VARCHAR(100) ,
"D_START" TIMESTAMP ,
"D_END" TIMESTAMP ,
"T_ELAPSED" TIME ,
"STATUS" VARCHAR(50) )
IN "CMW_DA16DN01" INDEX IN "CMW_IX16DN01" ;
------------------------------------------------
-- DDL Statements for table "CMWSYS"."CMWD_REF_MARCHE_AFFECTATION"
------------------------------------------------
CREATE TABLE "CMWSYS"."CMWD_REF_MARCHE_AFFECTATION" (
"CD_CSM" SMALLINT NOT NULL ,
"CD_SSE_3EME_CAR" CHAR(1) NOT NULL ,
"CD_TYP_PERS" CHAR(3) NOT NULL ,
"DT_VAL_DEB" DATE ,
"CLE_SS_COMPRT" SMALLINT NOT NULL ,
"DT_VAL_FIN" DATE ,
"TOP_COURANT" CHAR(1) ,
"TOP_ANNUL" CHAR(1) ,
"DT_MAJ_ETL" TIMESTAMP )
IN "DIM_DA16DN01" INDEX IN "DIM_IX16DN01" ;
COMMENT ON COLUMN "CMWSYS"."CMWD_REF_ZONE_MONETAIRE"."DT_MAJ_ETL" IS 'Date ETL chargement du flux';
COMMENT ON COLUMN "CMWSYS"."CMWD_REF_ZONE_MONETAIRE"."TOP_ANNUL" IS '1 annul�, 0 sinon';
The script should extract each table definition in one separate file (normal txt file) called dbname_tablename.txt. The "dbname" is the first word in the quotation marks after CREATE TABLE statement and the "tablename" is the string characters included in quotation marks after the '.' sign (for this case CMWSYS_CMWD_TEC_SUIVI_TRT or CMWSYS_CMWD_REF_MARCHE_AFFECTATION). All the others definitions (indexes) and the comments should be ignored..
Do you have any idea how I can manage this task? I still have no result with my humble script I am working at.
Thanks