DSLContext dsl = getDSLContext();
SelectOrderByStep<Record1<Integer>> allAssignments = dsl.select(RES_ISSUE_ASSIGNMENT.RESOURCEID_FK)
.from(RES_ISSUE_ASSIGNMENT)
.union(dsl.select(RES_RECEIPT_ASSIGNMENT.RESOURCEID_FK).from(RES_RECEIPT_ASSIGNMENT));
Result<ResourceRecord> resourceRecords = dsl.selectFrom(RESOURCE).where(RESOURCE.ID.notIn(allAssignments)).fetch();
The created SQL is throwing a derby exception:
Exception in thread "main" org.jooq.exception.DataAccessException: SQL [select "APP"."RESOURCE"."ID", "APP"."RESOURCE"."NAME", "APP"."RESOURCE"."TERMINAL_FK", "APP"."RESOURCE"."CAPACITY", "APP"."RESOURCE"."THROUGHPUT_GPM", "APP"."RESOURCE"."COMMENT" from "APP"."RESOURCE" where "APP"."RESOURCE"."ID" not in (select * from (select "APP"."RES_ISSUE_ASSIGNMENT"."RESOURCEID_FK" from "APP"."RES_ISSUE_ASSIGNMENT") x union select * from (select "APP"."RES_RECEIPT_ASSIGNMENT"."RESOURCEID_FK" from "APP"."RES_RECEIPT_ASSIGNMENT") x)]; 'SELECT *' only allowed in EXISTS and NOT EXISTS subqueries. at org.jooq_3.10.4.DERBY.debug(Unknown Source) at org.jooq.impl.Tools.translate(Tools.java:2239) at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:704) at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:361) at org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:317) at org.jooq.impl.SelectImpl.fetch(SelectImpl.java:2597)
--
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.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
SelectOrderByStep<Record1<Integer>> allAssignments = dsl.select(RES_ISSUE_ASSIGNMENT.RESOURCEID_FK)
.from(RES_ISSUE_ASSIGNMENT)
.union(dsl.select(RES_RECEIPT_ASSIGNMENT.RESOURCEID_FK).from(RES_RECEIPT_ASSIGNMENT));
System.out.println(allAssignments.getSQL());Results in:
select * from (select "APP"."RES_ISSUE_ASSIGNMENT"."RESOURCEID_FK" from "APP"."RES_ISSUE_ASSIGNMENT") x union select * from (select "APP"."RES_RECEIPT_ASSIGNMENT"."RESOURCEID_FK" from "APP"."RES_RECEIPT_ASSIGNMENT") x
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
Lukas,Thanks for looking into this. If it makes any difference, I can execute the query:SELECT *FROM RESOURCEWHERE ID NOT IN (SELECT RESOURCEID_FK FROM RES_ISSUE_ASSIGNMENTUNIONSELECT RESOURCEID_FK FROM RES_RECEIPT_ASSIGNMENT);
directly on the derby database (e.g. from using ij or jOOQ string query and it executes fine, returning the expected result. So, does this mean that derby does support the nested query. I will try the not exists approach and see what happens. Here is an excellent related blog post:
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
--
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/6uWwtl-4kpE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.