title: Search and find a string value in all columns
body: <p>I need to find if a string value exists in any column in my table.
  It's possible create automatically procedure or query in Firebird that perform this work without making explicit column names?</p>
  <p>Column names can be find with this query:</p>
  <blockquote>
  <p>select RDB$RELATION_FIELDS.rdb$field_name as NC from
  RDB$RELATION_FIELDS where RDB$RELATION_FIELDS.rdb$relation_name =
  MY_Table_name</p>
  </blockquote>
  <p>I would use a procedure similar to that in Firebird:</p>
  <p><a href="http://www.mssqltips.com/sqlservertip/1522/searching-and-finding-a-string-value-in-all-columns-in-a-sql-server-table/" rel="nofollow noreferrer">http://www.mssqltips.com/sqlservertip/1522/searching-and-finding-a-string-value-in-all-columns-in-a-sql-server-table/</a></p>
  <pre><code>SET TERM ^^ ;
  
  CREATE PROCEDURE P_FINDSTRINGINTABLE (
    STRTOFIND VarChar(255), 
    TBLNAME VarChar(255))
   returns (
    SQLCOMMAND VarChar(25000))
  AS
  DECLARE VARIABLE condSTR VARCHAR(8000);
  DECLARE VARIABLE columnName VARCHAR(8000);
  begin
    sqlCommand = 'select * from '|| upper( :TBLNAME );
    
    condSTR = '';
    for select RDB$RELATION_FIELDS.rdb$field_name as NC from RDB$RELATION_FIELDS where RDB$RELATION_FIELDS.rdb$relation_name = upper( :TBLNAME )
    into  :columnName  
    do begin
       condSTR = condSTR||columnName||' LIKE ''%'||STRTOFIND||'%'' OR ';   
    end
           
    
    
    IF ( CHAR_LENGTH(condSTR) &gt; 0 ) THEN 
    begin
       condSTR = ' where ' || left(condSTR, CHAR_LENGTH (condSTR)-3)  || ';';
       sqlCommand = sqlCommand|| condSTR;  
    end
    ELSE sqlCommand = sqlCommand||';' ;
  
    
  end ^^
  
  
  SET TERM ; ^^
  </code></pre>
  <p>I've created the right string SQL for my search.
  Now, if I execute this Firebird procedure, it returns the SQL command as string.</p>
  <p>Are there methods to automatically execute the returned select?</p>