I need to select all the values of a record.
I learned that it´s possible to select each value of the record separately using the DSL.val()
function.
Let´s say we have a record R
with the following properties:
name: String
, number: Int
. Selecting each value of the record separately would look like this:
R myRecord = new R()
ctx.select(val(myRecord.name), val(myRecord.number))
As you can guess this will get pretty tedious when you have a record with 15 properties.
Is it possible to select all values of a record instead of having to select each value separately?
I imagine something like this:
ctx.select(myRecord)
If you don't need the type safety, then you can use
Record.valuesRow()
.fields()
:This will produce a
Select<Record>
, whose number of columns is unknown to the compiler. If you prefer profiting from the additional type safety provided by your specificR
record type (I'm assuming e.g.Record2<String, Integer>
), then you can use thevalues()
constructor: