<< Creating a script from a Database Designer model file | IBEBlock | IBEBlock User Forms >>

Creating an UPDATE script with domain descriptions

The following IBEBlock creates a script with UPDATE statements for all database domains that have a description:

 execute ibeblock
   as
   begin
     FHSQL = ibec_fs_OpenFile('E:\DomDescs.sql', __fmCreate);
     FHBlobs = ibec_fs_OpenFile('E:\DomDescs.lob', __fmCreate);
     if ((not FHSQL is null) and (not FHBlobs is null)) then
     begin
       ibec_fs_Writeln(FHSQL, 'SET BLOBFILE 创E:\DomDescs.lob创;');
       ibec_fs_Writeln(FHSQL, 创);
       for select rdb$field_name, rdb$description
           from rdb$fields
           where (rdb$description is not null)
           order by 1
           into :FieldName, :FieldDesc
       do
       begin
         if (FieldDesc <> 创) then
         begin
           FieldName = ibec_Trim(FieldName);
           iOffs = ibec_fs_Position(FHBlobs);
           iLen = ibec_fs_WriteString(FHBlobs, FieldDesc);
           sParamName = ':h' || ibec_IntToHex(iOffs, 8) || '_' || ibec_IntToHex(iLen, 8);
           UpdStmt = 'UPDATE RDB$FIELDS' || ibec_Chr(13) || ibec_Chr(10) ||
                     'SET RDB$DESCRIPTION = ' || :sParamName ||
                     ibec_Chr(13) || ibec_Chr(10) ||
                     'WHERE (RDB$FIELD_NAME = 创' || FieldName || 创');';
           ibec_fs_Writeln(FHSQL, UpdStmt);
           ibec_fs_Writeln(FHSQL, 创);
         end
       end
       ibec_fs_Writeln(FHSQL, 'COMMIT WORK;');
       ibec_fs_CloseFile(FHSQL);
       ibec_fs_CloseFile(FHBlobs);
     end
     commit;
   end;

back to top of page
<< Creating a script from a Database Designer model file | IBEBlock | IBEBlock User Forms >>