Well, you could use jOOQ's transaction API, which turns auto-commit off for
the scope of the transaction. E.g.:
ctx.transaction(c -> {
// Within this scope, c contains a ConnectionProvider with auto-commit
turned off
DSL.using(c).createTemporaryTable(...);
DSL.using(c).fetch(...);
});
Of course, you can also just write a more sophisticated ConnectionProvider
as documented here:
http://www.jooq.org/doc/latest/manual/sql-building/dsl-context/connection-vs-datasource
Or, you use Spring or Java EE or some other transaction API which manages
the auto-commit flag for you.
As you can see, you have tons of options :)
Cheers,
Lukas
2015-07-21 16:04 GMT+02:00 Juri Krainjukov <[email protected]>:
> The problem is I don't want to turn it off for all queries.
>
>
> On Tuesday, July 21, 2015 at 5:01:00 PM UTC+3, Juri Krainjukov wrote:
>>
>> Is it possible to do it through DSLContext?
>>
>> On Tuesday, July 21, 2015 at 4:55:51 PM UTC+3, Lukas Eder wrote:
>>>
>>> I suspect you should turn off auto-commit in your JDBC driver...?
>>>
>>> 2015-07-21 15:43 GMT+02:00 Juri Krainjukov <[email protected]>:
>>>
>>>> I'm trying to create a temporary table and use it with JOOQ.
>>>>
>>>> Here's the query I use directly on DB and it works.
>>>>
>>>> CREATE TEMPORARY TABLE temp_table_1
>>>> ON COMMIT DROP
>>>> AS
>>>> SELECT a1 FROM table1;
>>>>
>>>> select * from func_uses_temp_table();
>>>>
>>>>
>>>> I tried to use
>>>>
>>>> createTemporaryTable("t1").as(query).onCommitDrop().execute();
>>>>
>>>> and then
>>>>
>>>> fetch("select * from t1");
>>>>
>>>> but it fails with message "jOOQ; bad SQL grammar [select * from t1];
>>>> nested exception is org.postgresql.util.PSQLException: ERROR: relation "t1"
>>>> does not exist Position: 15"
>>>>
>>>>
>>>> So what would be the correct way to use temporary tables in queries?
>>>>
>>>>
>>>>
>>>> --
>>>> 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.
>
--
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.