SmartFB is a free SQL client for Interbase and Firebird made for internal / educational use. As we think it will be useful we decided to make it available for download. It is in “beta” version, but I think it could be useful, so you can download it from the following links: – Download Windows…
Leggi tutto
Primo test di porting database alla versione Firebird 3.0 che è la versione ufficialmente afficancata ai pacchetti di distribuzione standard di Ubuntu nella versione LTS attuale 18.04. Le differenze tra la versione 3.0 di FB e le precedenti sono moltissime. Ma i passaggi sono abbastanza semplici per effettuare il porting dalle versioni precedenti alla attuale…
Leggi tutto
1 2 3 4 |
select PK_ID from USERS start with FK_USER_PARENT = PK_USER connect by prior PK_ID = FK_USER_PARENT; |
To enable and disable all triggers of a database i do two procedure : Enabling all database trigger:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
create procedure SP_ENABLE_ALL_TRIGGER as begin /* Procedure Text */ update RDB$TRIGGERS set RDB$TRIGGER_INACTIVE=0 where RDB$TRIGGER_NAME in( select A.RDB$TRIGGER_NAME from RDB$TRIGGERS A left join RDB$CHECK_CONSTRAINTS B ON B.RDB$TRIGGER_NAME = A.RDB$TRIGGER_NAME where ((A.RDB$SYSTEM_FLAG = 0) or (A.RDB$SYSTEM_FLAG is null)) and (b.rdb$trigger_name is null) AND (NOT(A.RDB$TRIGGER_NAME LIKE 'RDB$%')) ); suspend; end |
Disabling all database trigger:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
create procedure SP_DISABLE_ALL_TRIGGER as begin update RDB$TRIGGERS set RDB$TRIGGER_INACTIVE=1 where RDB$TRIGGER_NAME in( select A.RDB$TRIGGER_NAME from RDB$TRIGGERS A left join RDB$CHECK_CONSTRAINTS B ON B.RDB$TRIGGER_NAME = A.RDB$TRIGGER_NAME where ((A.RDB$SYSTEM_FLAG = 0) or (A.RDB$SYSTEM_FLAG is null)) and (b.rdb$trigger_name is null) AND (NOT(A.RDB$TRIGGER_NAME LIKE 'RDB$%')) ); suspend; end |
With that simple peace of code you can retrive the full list of all “FK” Foreign Key of an Interbase or Firebird DB.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
SELECT rc.RDB$CONSTRAINT_NAME AS constraint_name, i.RDB$RELATION_NAME AS table_name, s.RDB$FIELD_NAME AS field_name, i.RDB$DESCRIPTION AS description, rc.RDB$DEFERRABLE AS is_deferrable, rc.RDB$INITIALLY_DEFERRED AS is_deferred, refc.RDB$UPDATE_RULE AS on_update, refc.RDB$DELETE_RULE AS on_delete, refc.RDB$MATCH_OPTION AS match_type, i2.RDB$RELATION_NAME AS references_table, s2.RDB$FIELD_NAME AS references_field, (s.RDB$FIELD_POSITION + 1) AS field_position FROM RDB$INDEX_SEGMENTS s LEFT JOIN RDB$INDICES i ON i.RDB$INDEX_NAME = s.RDB$INDEX_NAME LEFT JOIN RDB$RELATION_CONSTRAINTS rc ON rc.RDB$INDEX_NAME = s.RDB$INDEX_NAME LEFT JOIN RDB$REF_CONSTRAINTS refc ON rc.RDB$CONSTRAINT_NAME = refc.RDB$CONSTRAINT_NAME LEFT JOIN RDB$RELATION_CONSTRAINTS rc2 ON rc2.RDB$CONSTRAINT_NAME = refc.RDB$CONST_NAME_UQ LEFT JOIN RDB$INDICES i2 ON i2.RDB$INDEX_NAME = rc2.RDB$INDEX_NAME LEFT JOIN RDB$INDEX_SEGMENTS s2 ON i2.RDB$INDEX_NAME = s2.RDB$INDEX_NAME WHERE rc.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY s.RDB$FIELD_POSITION |
Hi, I think might be helpful, today for a customer i do the Haversine formulas for Firebird Sql as a stored procedure. This formula allow you to calculate the distance in meter between two WGS84 datum points(degree points of Earth). You can call the procedure like this:
1 |
SELECT * FROM HAVERSINE_GENERIC(1, 45,474081, 9,179348, 45,456091, 9) |
The result wil be aprox 14Km, the…
Leggi tutto