Ok Lukas I think I've figured this out but let me run my solution by you to 
ensure I'm going about it the best way possible.

First thing I did was implement an *ExecuteListener * by extending 
*DefaultExecuteListener*


public class ParamsListener extends DefaultExecuteListener {

@Override
    public void executeStart(ExecuteContext ctx) {
try {
ctx.connection().createStatement().execute("SET enable_sort to true");
} catch (SQLException e) {
e.printStackTrace();
}
}

    @Override
    public void executeEnd(ExecuteContext ctx) {
    try {
  ctx.connection().createStatement().execute("RESET enable_sort");
  } catch (SQLException e) {
  e.printStackTrace();
  }
    }
}





On Wednesday, December 2, 2015 at 11:43:52 AM UTC-5, Max Kremer wrote:
>
> Hi Lukas,
>
>   I need to be able to run the statements ad-hoc. What I mean by that is I 
> need them for some queries and not others, it's not something I want to 
> universally apply across all connections or transactions. Ideally I'd do it 
> from the DSLContext...
>
>
> On Wednesday, December 2, 2015 at 5:13:54 AM UTC-5, Lukas Eder wrote:
>>
>> There are many ways to accomplish this with jOOQ. The most 
>> straightforward way is to implement this inside of a ConnectionProvider 
>> (call SET on acquire() and RESET on release()). Another solution would be 
>> to hook into the transaction lifecycle and run the statements at the 
>> beginning and at the end of a transaction.
>>
>> When do you want to run the statements?
>>
>> 2015-12-01 20:31 GMT+01:00 Max Kremer <[email protected]>:
>>
>>>
>>>
>>> In PostGres (as well other DBs I've used) you can set runtime params 
>>> that affect the query and/or result. This is accomplished with the use of 
>>> SET and RESET as described here 
>>> <http://www.postgresql.org/docs/9.4/static/sql-set.html>
>>>
>>>
>>>
>>> SET search_path TO my_schema, public
>>> SELECT * from foo
>>> RESET search_path
>>>
>>>
>>> I can't seem to find a way to accomplish this with JOOQ.
>>>
>>> Thanks in advance for any pointers.
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "jOOQ User Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to