Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Posts
    3

    Unanswered: Informix Function - Dynamic where clause

    Hi,

    How to implement dynamic where clause in Informix Function?
    Here is my code:

    Create Function testFun(pv_dept integer)

    RETURNING varchar(20), varchar(70);

    Define lv_Name varchar(20);
    Define lv_Details varchar(70);

    FOREACH
    Select name, details into lv_Name, lv_Details
    from EMP where job='Manager'
    -- have to add the following condition based on parameter
    -- if parameter is null then display all
    -- else display only that dept
    and depet_no = pv_dept


    return lv_Name, lv_Details WITH RESUME;

    End FOREACH;

    END FUNCTION;

    Thank you

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    Hi,
    there is no need for dynamic where clause, the conditions you posted with application of appropriate logical operation will satisfy the requirement:
    Code:
    WHERE job='Manager'
       AND (pv_dept is null OR depet_no = pv_dept)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •