Search code examples
sqlstringfunctionoracle11gjdeveloper

Sql help, function parses a string field in table, need to filter returned table in where clause


I need some help, I am using Oracle 11g 11.1.2.4, and Jdeveloper

I need the 'Type' returned from my function to be filtered in the where clause so that any 'Type' that is 'NO_TYPE' is not returned.

I have a SQL statement like the following:

Where 'String_Finder' is a function I created to parse the field in the table.
      'Log_Table' is the table I am accessing.
      'Message' is the field in the table I am parsing.

SQL:

Select
        String_Finder(Log_Table.Message, 1, 2) AS Type
From
        LOG Log_Table
Where
       [ this is where I need help --- I need to filter Type based on the word 'NO_TYPE']

My function:

"String_Finder" (p_message in VARCHAR2, first_field NUMBER, second_field NUMBER) RETURN AS VARCHAR2 AS

v_posA NUMBER;
v_posB NUMBER;

BEGIN
      v_posA := INSTR(p_message, '|', 1, first_field) + 1;
      v_posB := INSTR(p_message, '|', 2, second_field)

RETURN SUBSTR(p_message, v_posA, (v_posB - v_posA));
END;

Solution

  • It should just be:

    WHERE String_Finder(Log_Table.Message, 1, 2) NOT LIKE 'NO_TYPE'