Subject Re: [SPAM] Re: [firebird-support] Firebird : find strign in all database
Author Neville Richards
What you’ve written is a valiant effort, but shows why I think it’s better to use external programming to generate the SQL needed.  Programming languages like c, c++, pascal etc., give far more fine control in doing such a task, have well-defined control statements, and are able to be debugged statement by statement to find errors which are so easy to make.  A typical error in putting together such code to create SQL where it will contain a concatenation of many parts, some literal and some variable, it the simple omission of space characters where they are needed.
 
I’m afraid that I have used the procedural bits of Firebird SQL very little, and always find it a stress when I have to.  It seems very clunky and difficult to manage to me, compared with programming languages which are designed to be procedural.
 
Neville
 
Sent: Wednesday, January 11, 2017 9:02 AM
Subject: [SPAM] Re: [firebird-support] Firebird : find strign in all database
 
 

Hi thanks for your reply

 

i have this code but something gone wrong

 

SET TERM !;

EXECUTE BLOCK

RETURNS (DANSTABLE CHAR(31), DANSCOLONNE CHAR(31) )

AS

DECLARE VARIABLE STMT VARCHAR(250);

DECLARE VARIABLE CHAINE VARCHAR(50);

DECLARE VARIABLE RESULT SMALLINT;

BEGIN

CHAINE='ACHERCHER';

 FOR SELECT r.RDB$FIELD_NAME,

    r.RDB$RELATION_NAME

    FROM RDB$RELATION_FIELDS r LEFT JOIN RDB$FIELDS F ON r.RDB$FIELD_SOURCE = f.RDB$FIELD_NAME

    WHERE r.RDB$SYSTEM_FLAG=0 AND f.RDB$FIELD_TYPE IN (37,14) AND f.RDB$FIELD_LENGTH>=9

    INTO :DANSCOLONNE,:DANSTABLE

DO BEGIN

   STMT='SELECT 1 FROM '||:DANSTABLE||' WHERE '||:DANSCOLONNE||' = ?';

   EXECUTE STATEMENT (STMT) (CHAINE) INTO :RESULT;   

   IF (RESULT IS NOT NULL) THEN SUSPEND;

 END 

END!

 

SET TERM ; !