Created
November 20, 2019 09:52
-
-
Save yukithm/79846495cd286f93bf95c6b7500c17da to your computer and use it in GitHub Desktop.
[kotlin] jOOQ: PostgreSQL's setval() for DSLContext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.jooqext | |
import org.jooq.DSLContext | |
import org.jooq.Sequence | |
import org.jooq.impl.DSL | |
fun <T : Number> DSLContext.setval(sequence: Sequence<T>, value: T, isCalled: Boolean = true) = | |
select( | |
DSL.field( | |
"setval({0}, {1}, {2})", | |
Long::class.java, | |
sequence.qualifiedName.unquotedName().toString(), | |
value, | |
isCalled | |
) | |
).fetchOne(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: