ibec_CompareMetadata

Compares the metadata of specified databases and creates a script of all discrepancies.

Syntax

 function ibec_CompareMetadata(MasterDB : variant; SubscriberDB :variant;
                               ScriptFile : string; Options : string;
                               CallbackBlock : variant) : string;

Description

This function compares the metadata of two databases (or scripts) and creates a discrepancy script.

Note: Object filtering was implemented in IBExpert version 2020.02.13. To exclude some database objects from the comparison it is necessary to process them in the callback block. For example see the IBEBlock page in the Database Comparer form.

Parameters

MasterDBReference database or script file.
SubscriberDBComparative database or script file.
ScriptFileName of the difference script file.
OptionsList of options, delimited with semicolon; possible options are:
NoConnectIf this option is specified in the option string the result script will not contain CONNECT statement and corresponding SET NAMES, SET SQL DIALECT and SET CLIENTLIB directives.
AlterViewsIf this option is ON, the Database Comparer will alter modified views instead of dropping and creating them again. This enables the alteration of a modified view even if somebody is still using it.
OmitDomains(Domains=0) don't compare domains.
OmitTables(Tables=0) don't compare tables.
OmitViews(Views=0) don't compare views.
OmitTriggers(Triggers=0) don't compare triggers.
OmitProcedures(Procedures=0) don't compare procedures.
OmitGenerators(Generators=0 don't compare generators.
OmitExceptions(Exceptions=0) don't compare exceptions.
OmitUDFs(UDFs=0) don't compare UDFs.
OmitRoles(Roles=0) don't compare roles.
OmitIndices(Indices=0) don't compare indices.
OmitGrants(Grants=0) don't compare privileges.
OmitUserGrants(UserGrants=0) don't compare user privileges.
OmitRoleGrants(RoleGrants=0) don't compare role privileges.
OmitObjectGrants(ObjectGrants=0) don't compare database object privileges.
OmitDescriptions(Descriprions=0) don't compare object descriptions.
OmitPrimaryKeys(PrimaryKeys=0) don't compare primary keys.
OmitForeignKeys(ForeignKeys=0) don't compare foreign keys.
OmitUniques(Uniques=0) don't compare unique constraints.
OmitChecks(Checks=0) don't compare check constraints.
OmitFunctionsThis option skips stored functions while extracting and comparing metadata.
OmitPackagesThis option skips packages while extracting and comparing metadata.
SafeDatatypeConversion(SafeDatatypeConversion=1) Use only safe data type conversion (don't update system tables directly).
IgnoreColumnPositionsdon't compare column positions.
IgnoreIBEObjectsdon't compare IBE$xxx objects
IgnoreCharsetsWhen specified, character sets of domain/fields/parameters will be ignored during the comparison process.
ServerVersionPossible values are:
IB4x - for InterBase 4.x;
IB5x - for InterBase 5.x;
IB6x - for InterBase 6.x;
IB7x - for InterBase 7.x;
IB75 - for InterBase 7.5;
FB1x - for Firebird 1.x;
FB15 - for Firebird 1.5;
FB20 - for Firebird 2.0;
FB21 - for Firebird 2.1;
FB25 - for Firebird 2.5;
FB30 - for Firebird 3.0;
YA1x - for Yaffil 1.x.
If the ServerVersion is not specified, FB15 will be used.
ReturnBy default, ibec_CompareMetadata returns null, but it is possible to force it to return the total number of actions (CREATE/ALTER/DROP etc.) in the result script: specify Return=ActionCount in the option string. Normally ActionCount = 0 if there are no differences found.
AppendModeIf this option is specified and the file ScriptFile already exists the resulting script will be appended to the ScriptFile. Otherwise a new file will be created or an existing file will be overwritten.
CallbackBlockA callback IBEBlock which will be executed for each record processed whilst comparing data. The callback IBEBlock must have at least one input parameter, which will be used to pass a number of processed records within it.

Examples of usage

1. Comparing databases:

   execute ibeblock
   as
   begin
      create connection MasterDB dbname 'localhost:c:\MasterDB.fdb'
      password 'masterkey' user 'SYSDBA'
      clientlib 'C:\Program Files\Firebird\bin\fbclient.dll';

      create connection SubscriberDB dbname 'localhost:c:\SubscriberDB.fdb'
      password 'masterkey' user 'SYSDBA'
      sql_dialect 3
      clientlib 'C:\Program Files\Firebird\bin\fbclient.dll';


      cbb = 'execute ibeblock (LogMessage variant)
             as
             begin
               ibec_progress(LogMessage);
             end';

      ibec_CompareMetadata(MasterDB, SubscriberDB, 'E:\CompRes.sql', 'OmitDescriptions; OmitGrants', cbb);

      close connection MasterDB;
      close connection SubscriberDB;
   end

2. Comparing scripts:

   execute ibeblock
   as
   begin
     cbb = 'execute ibeblock (LogMessage variant)
            as
            begin
              ibec_progress(LogMessage);
            end';

     ibec_CompareMetadata('c:\myscripts\master.sql','c:\myscripts\subscriber.sql', 'E:\CompRes.sql','', cbb);
   end

3. Using the ServerVersion parameter:

   ibec_CompareMetadata(MasterDB, 
                        SubscriberDB, 
                        'E:\CompRes.sql', 
                        'OmitDescriptions; OmitGrants; ServerVersion=FB1x;', 
                        cbb);

See also:
Comparing databases using IBEBlock
Comparing scripts with IBEBlock
Extract metadata using IBEBlock
IBEBlocks

back to top of page
<< ibec_CompareTables | IBEBlock | ibec_ExtractMetadata >>