Generate insert ( or update ) statements with jOOQ?

13 views
Skip to first unread message

Kirusanth Poopalasingam

unread,
Feb 27, 2018, 4:10:06 PM2/27/18
to jOOQ User Group

Hi Lukas, 

Is there a way to get the insert statement as String than executing it? 

Something like this would be nice: 

Result<EventLogRecord> result = dslContext.selectFrom(Tables.T_EVENT_LOG)
.fetch();

EventLogRecord eventLogRecord = result.get(0);
// I can do this
eventLogRecord.insert();

// but I'm only interested in the sql statement
String sqlInsert = eventLogRecord.insertAsSql();


Thanks, 
Kiru 

Lukas Eder

unread,
Feb 28, 2018, 5:06:06 AM2/28/18
to jooq...@googlegroups.com
Yes, call Query.getSQL() (and Query.getBindValues()) to extract this information:

--
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 jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Poopalasingam Kirusanth

unread,
Feb 28, 2018, 8:06:41 AM2/28/18
to jooq...@googlegroups.com

Thank you, that's even better than I expected. 

Cheers, 
Kiru

--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/UVKiGUieNuo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Mit freundlichen Grüssen
Kirusanth Poopalasingam
Reply all
Reply to author
Forward
0 new messages