Topic
2 replies Latest Post - ‏2012-03-23T20:11:34Z by SystemAdmin
SystemAdmin
SystemAdmin
345 Posts
ACCEPTED ANSWER

Pinned topic Using Dynamic SQL

‏2012-03-01T18:24:29Z |
Hi,

There are two methods available to override to implement dynamic query.

a.getSQLStatement()
b.provideSQLStatement()

Can any one please tell what is the difference between the two?

Thanks!
Updated on 2012-03-23T20:11:34Z at 2012-03-23T20:11:34Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    345 Posts
    ACCEPTED ANSWER

    Re: Using Dynamic SQL

    ‏2012-03-02T10:13:28Z  in response to SystemAdmin
    Hi,

    If you are writing a BObjQuery class which extends GenericBObjQuery, then you can implement either provideSQLStatement or getSQLStatement to return the required SQL. The SQL returned by provideSQLStatement will be used in preference to the SQL returned by getSQLStatement.

    The methods modifySQLStatement and getOrderByStatement are applied to the SQL returned by getSQLStatement, but the default implementations of these methods don't do anything - so practically, for dynamic SQL you can implement either provideSQLStatement or getSQLStatement, the results would be the same.

    The default implementation of provideSQLStatement returns null. The default implementation of getSQLStatement retrieves the SQL from the query interface class returned by provideQueryInterfaceClass.

    You may find my article on writing custom query transactions helpful: http://www.ibm.com/developerworks/data/tutorials/dm-1111customquerymdm/

    Hope that helps, Catherine.