Hello,
I'm new to Jooq, but I have to modify a part of a query.
Here I have the existing part of the query which was working well:
<code>
...
this.select(REG_ORG.NAAM)
.from(REG_ORG)
.where(REG_ORG.ID.eq(OVR_OVERTREDING.HANDHAVING_DOOR_ID))
.asField<String>(),
this.select(DSL.coalesce ...
</code>
Now I have change the query like this:
<code>
...
this.select(REG_ORG.NAAM)
.from(REG_ORG)
.where(REG_ORG.ID.eq(OVR_OVERTREDING.HANDHAVING_DOOR_ID))
.union(select(REG_ORG.NAAM)
.from(REG_ORG)
.join(REG_MEDEWERKER).on(REG_MEDEWERKER.ORGANISATIE_ID.eq(REG_ORG.ID)
.and(REG_MEDEWERKER.GEBRUIKER_ID.eq(gebruikerId.value))))
.asField<String>(),
this.select(DSL.coalesce ...
</code>
So I have extend this with a union. In console I get the SQL query and If run this part in the "Query console" than I get the result which I expected. But In the console of IntelliJ I get the Error: "org.postgresql.util.PSQLException: ERROR: more than one row returned by a subquery used as an expression"
If add only the new union part without the existing is working also. But the combination of the two queries (union) is not working.
I try to find out what asField<String>() mean. My feeling is that the it need to be a field in the Select with the generic String.