// Use StructEx.utl // Restructuring extensions Use Fdx_Attr.utl // FDX compatible attribute functions Use Structur.utl // Object for restructuring table definitions function RSX_CreateTableFromFDX global integer lhFDX integer liFile string lsRoot returns integer integer liField liMax liIndex liSegment liMaxSegment liTmp integer liLockType liType liRelFile liRelField liMainIndex liDir integer liValue string lsRN if lsRoot ne "" move lsRoot to lsRN else move (FDX_AttrValue_FILELIST(lhFDX,DF_FILE_ROOT_NAME,liFile)) to lsRN // get DBMS_StripPathAndDriver lsRN to lsRN // get HowManyWords lsRN "/\:" to liTmp // if (liTmp<>1) get ExtractWord lsRN "/\:" liTmp to lsRN // get rid of driver and path if lsRN ne "" begin if (RS_TableCreateName(lsRN)) begin // Create fields: move (FDX_AttrValue_FILE(lhFDX,DF_FILE_NUMBER_FIELDS,liFile)) to liMax for liField from 1 to liMax move (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_TYPE,liFile,liField)) to liType send RS_AppendField (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_NAME,liFile,liField)) liType if liType ne DF_DATE ; send RS_SetFieldAttr DF_FIELD_LENGTH IMPLICIT_FIELD (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_LENGTH,liFile,liField)) if liType eq DF_BCD ; send RS_SetFieldAttr DF_FIELD_PRECISION IMPLICIT_FIELD (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_PRECISION,liFile,liField)) move (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_RELATED_FILE,liFile,liField)) to liRelFile move (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_RELATED_FIELD,liFile,liField)) to liRelField move (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_INDEX,liFile,liField)) to liMainIndex if liRelFile send RS_SetFieldAttr DF_FIELD_RELATED_FILE IMPLICIT_FIELD liRelFile if liRelField send RS_SetFieldAttr DF_FIELD_RELATED_FIELD IMPLICIT_FIELD liRelField if liMainIndex send RS_SetFieldAttr DF_FIELD_INDEX IMPLICIT_FIELD liMainIndex if liType eq DF_OVERLAP ; send RS_SetFieldAttr DF_FIELD_OFFSET IMPLICIT_FIELD (FDX_AttrValue_FIELD(lhFDX,DF_FIELD_OFFSET,liFile,liField)) loop for liIndex from 1 to 15 move (integer(FDX_AttrValue_INDEX(lhFDX,DF_INDEX_NUMBER_SEGMENTS,liFile,liIndex))) to liMaxSegment if liMaxSegment begin send RS_SetIndexAttr DF_INDEX_NUMBER_SEGMENTS liIndex liMaxSegment for liSegment from 1 to liMaxSegment send RS_SetIndexSegAttr DF_INDEX_SEGMENT_FIELD liIndex liSegment (FDX_AttrValue_IDXSEG(lhFDX,DF_INDEX_SEGMENT_FIELD ,liFile,liIndex,liSegment)) get FDX_AttrValue_IDXSEG lhFDX DF_INDEX_SEGMENT_DIRECTION liFile liIndex liSegment to liDir send RS_SetIndexSegAttr DF_INDEX_SEGMENT_DIRECTION liIndex liSegment liDir // (FDX_AttrValue_IDXSEG(lhFDX,DF_INDEX_SEGMENT_DIRECTION,liFile,liIndex,liSegment)) send RS_SetIndexSegAttr DF_INDEX_SEGMENT_CASE liIndex liSegment (FDX_AttrValue_IDXSEG(lhFDX,DF_INDEX_SEGMENT_CASE ,liFile,liIndex,liSegment)) loop send RS_SetIndexAttr DF_INDEX_TYPE liIndex (FDX_AttrValue_INDEX(lhFDX,DF_INDEX_TYPE,liFile,liIndex)) end loop // File parameters: move (FDX_AttrValue_FILE(lhFDX,DF_FILE_MAX_RECORDS ,liFile)) to liValue if (liValue>16711679) move 16711679 to liValue send RS_SetFileAttr DF_FILE_MAX_RECORDS liValue send RS_SetFileAttr DF_FILE_MULTIUSER (FDX_AttrValue_FILE(lhFDX,DF_FILE_MULTIUSER ,liFile)) send RS_SetFileAttr DF_FILE_REUSE_DELETED (FDX_AttrValue_FILE(lhFDX,DF_FILE_REUSE_DELETED ,liFile)) send RS_SetFileAttr DF_FILE_COMPRESSION (FDX_AttrValue_FILE(lhFDX,DF_FILE_COMPRESSION ,liFile)) send RS_SetFileAttr DF_FILE_RECORD_LENGTH (FDX_AttrValue_FILE(lhFDX,DF_FILE_RECORD_LENGTH ,liFile)) send RS_SetFileAttr DF_FILE_INTEGRITY_CHECK (FDX_AttrValue_FILE(lhFDX,DF_FILE_INTEGRITY_CHECK,liFile)) move (FDX_AttrValue_FILE(lhFDX,DF_FILE_TRANSACTION ,liFile)) to liValue if (liValue=DF_FILE_TRANSACTION_SERVER_LOGGED) move DF_FILE_TRANSACTION_CLIENT_ATOMIC to liValue send RS_SetFileAttr DF_FILE_TRANSACTION liValue // Mysteriously we have to 'fork' lock type in place. Apparently // DF_FILE_LOCK_TYPE *may* return 255, which is not a legal value. move (FDX_AttrValue_FILE(lhFDX,DF_FILE_LOCK_TYPE,liFile)) to liLockType if (liLockType<>DF_LOCK_TYPE_NONE and liLockType<>DF_LOCK_TYPE_FILE and liLockType<>DF_LOCK_TYPE_RECORD) move DF_LOCK_TYPE_FILE to liLockType if (liLockType=DF_LOCK_TYPE_RECORD) move DF_LOCK_TYPE_FILE to liLockType send RS_SetFileAttr DF_FILE_LOCK_TYPE liLockType send RS_Structure_End function_Return 1 end end function_return 0 end_function