Plex 2E

 View Only
  • 1.  Dynamic SQL statement

    Posted May 24, 2014 04:22 PM

    I'm trying to dynamically build the where clause of a sql statement in a source code object.    Does anyone have any suggestions for doing this?

    Exec SQL  Source code: SQL Statement, SQLData

    SQL Statement = Select FirstName, LastName, Address From Employee Where &(1:)

    &(1:) = "State = 'LA' and Zip = '70115'"



  • 2.  RE: Dynamic SQL statement
    Best Answer

    Posted May 25, 2014 05:37 AM


    I would suggest that you take a look into the Filter entity from the Foundation Lib.
    It does what you want as it composes a dynamic where statement from the given conditions (filters in select criteria).

    After understanding how it works there, you should be able to build your own dynamic query generator adapting the metacode without too much effort.

    I don't know if anyone has any better suggestion?


  • 3.  RE: Dynamic SQL statement

    Posted May 25, 2014 11:11 AM

    I probably didn't explain the issue I was having correctly.  No problem generating the where clause but the issue was passing it into the source object.  Your reply did allow me to find the SQL statement type = Unprepared tripple that solved the problem.  Thanks for the reply.