Search code examples
sqldatabasenullfirebirdvarchar

NULL Characters in Firebird VARCHAR


Im trying to find records in a VARCHAR column that may contain a NUL (0x00), and I cannot find a way to locate the NUL character.

Any ideas are welcome.

-Israel


Solution

  • Firebird comes with an external function library (UDF library) that has an ASCII_CHAR function. You have to declare it in your database like this:

    DECLARE EXTERNAL FUNCTION ascii_char
    INTEGER
    RETURNS CSTRING(1) FREE_IT
    ENTRY_POINT 'IB_UDF_ascii_char' MODULE_NAME 'ib_udf'; */
    

    Then, you could try querying:

    select * from yourtable where column like '%' || ASCII_CHAR(0) || '%'
    

    or something similar...

    I must admit I haven't tried it, but you could and let us know the results :)