If there is no possibility in FireBird 2.5 add a structure like MySQL then how to properly check the presence of the table being created.

The question concerns the dynamic creation of tables by the script.

    1 answer 1

    Are available. It is necessary to check the presence of records in the system table RDB $ RELATIONS. But there is a nuance! IF works only in psql, but you cannot do CREATE in it. Therefore it is necessary to wrap twice. IF in EXECUTE BLOCK, and CREATE in EXECUTE STATEMENT. Here is an example:

     EXECUTE BLOCK AS BEGIN IF (NOT EXISTS(SELECT * FROM RDB$RELATIONS WHERE RDB$RELATION_NAME = 'MY_TABLE')) THEN EXECUTE STATEMENT ' CREATE TABLE MY_TABLE ( ID INTEGER NOT NULL, NAME VARCHAR(30) NOT NULL )'; END 
    • If it happens inside the procedure, then EXECUTE BLOCK is not needed, because you already write the procedure in psql - German Borisov