diff --git a/jOOQ-test/src/org/jooq/test/PostgresTest.java b/jOOQ-test/src/org/jooq/test/PostgresTest.java
index 45d0eba616..6abdf7c25b 100644
--- a/jOOQ-test/src/org/jooq/test/PostgresTest.java
+++ b/jOOQ-test/src/org/jooq/test/PostgresTest.java
@@ -36,6 +36,7 @@
package org.jooq.test;
+import static org.jooq.test.postgres.generatedclasses.Routines.fSearchBook;
import static org.jooq.test.postgres.generatedclasses.Tables.T_639_NUMBERS_TABLE;
import static org.jooq.test.postgres.generatedclasses.Tables.T_725_LOB_TEST;
import static org.jooq.test.postgres.generatedclasses.Tables.T_785;
@@ -840,4 +841,16 @@ public class PostgresTest extends jOOQAbstractTest<
.fetchOne(0));
}
+
+ @Test
+ public void testPostgresTableFunction() throws Exception {
+
+ // TODO [#1139] Further elaborate this test
+ create().select().from(fSearchBook("Animal", 1L, 0L).toString()).fetch();
+ System.out.println(create().select(fSearchBook("Animal", 1L, 0L)).fetch());
+
+ // This doesn't work, as jOOQ doesn't know how to correctly register
+ // OUT parameters for the returned cursor
+ // Object result = Routines.fSearchBook(create(), "Animal", 1L, 0L);
+ }
}
diff --git a/jOOQ-test/src/org/jooq/test/postgres/create.sql b/jOOQ-test/src/org/jooq/test/postgres/create.sql
index 341a8b9383..6d7c61dc04 100644
--- a/jOOQ-test/src/org/jooq/test/postgres/create.sql
+++ b/jOOQ-test/src/org/jooq/test/postgres/create.sql
@@ -26,6 +26,7 @@ DROP FUNCTION f317(p1 int, p2 int, p3 int, p4 int);/
DROP FUNCTION p_get_two_cursors(books OUT refcursor, authors OUT refcursor)/
DROP FUNCTION p_get_one_cursor(total OUT int, books OUT refcursor, book_ids in int[])/
DROP FUNCTION f_get_one_cursor(book_ids IN int[])/
+DROP FUNCTION f_search_book(p_title character varying, p_limit bigint, p_offset bigint)/
DROP TRIGGER IF EXISTS t_triggers_trigger ON t_triggers/
DROP FUNCTION p_triggers()/
@@ -449,6 +450,16 @@ CREATE VIEW v_book AS
SELECT * FROM t_book
/
+CREATE OR REPLACE FUNCTION f_search_book(p_title character varying, p_limit bigint, p_offset bigint)
+ RETURNS SETOF t_book AS
+$BODY$
+SELECT * FROM t_book
+WHERE (LOWER(title) LIKE LOWER('%' || p_title || '%'))
+LIMIT p_limit OFFSET p_offset;
+$BODY$
+ LANGUAGE sql VOLATILE
+ COST 100
+ ROWS 1000;
CREATE FUNCTION p_unused (in1 VARCHAR, out1 OUT INT, out2 IN OUT INT)
AS $$
diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java
index 2c29322650..24a191d021 100644
--- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java
+++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java
@@ -216,6 +216,43 @@ public final class Routines {
return f.asField();
}
+ /**
+ * Call public.f_search_book
+ */
+ public static java.lang.Object fSearchBook(org.jooq.Configuration configuration, java.lang.String pTitle, java.lang.Long pLimit, java.lang.Long pOffset) {
+ org.jooq.test.postgres.generatedclasses.routines.FSearchBook f = new org.jooq.test.postgres.generatedclasses.routines.FSearchBook();
+ f.setPTitle(pTitle);
+ f.setPLimit(pLimit);
+ f.setPOffset(pOffset);
+
+ f.execute(configuration);
+ return f.getReturnValue();
+ }
+
+ /**
+ * Get public.f_search_book as a field
+ */
+ public static org.jooq.Field fSearchBook(java.lang.String pTitle, java.lang.Long pLimit, java.lang.Long pOffset) {
+ org.jooq.test.postgres.generatedclasses.routines.FSearchBook f = new org.jooq.test.postgres.generatedclasses.routines.FSearchBook();
+ f.setPTitle(pTitle);
+ f.setPLimit(pLimit);
+ f.setPOffset(pOffset);
+
+ return f.asField();
+ }
+
+ /**
+ * Get public.f_search_book as a field
+ */
+ public static org.jooq.Field fSearchBook(org.jooq.Field pTitle, org.jooq.Field pLimit, org.jooq.Field pOffset) {
+ org.jooq.test.postgres.generatedclasses.routines.FSearchBook f = new org.jooq.test.postgres.generatedclasses.routines.FSearchBook();
+ f.setPTitle(pTitle);
+ f.setPLimit(pLimit);
+ f.setPOffset(pOffset);
+
+ return f.asField();
+ }
+
/**
* Call public.f317
*/
@@ -259,8 +296,8 @@ public final class Routines {
/**
* Call public.p_arrays
*/
- public static java.lang.Long[] pArrays2(org.jooq.Configuration configuration, java.lang.Long[] inArray) {
- org.jooq.test.postgres.generatedclasses.routines.PArrays2 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays2();
+ public static java.lang.String[] pArrays3(org.jooq.Configuration configuration, java.lang.String[] inArray) {
+ org.jooq.test.postgres.generatedclasses.routines.PArrays3 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays3();
p.setInArray(inArray);
p.execute(configuration);
@@ -281,8 +318,8 @@ public final class Routines {
/**
* Call public.p_arrays
*/
- public static java.lang.String[] pArrays3(org.jooq.Configuration configuration, java.lang.String[] inArray) {
- org.jooq.test.postgres.generatedclasses.routines.PArrays3 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays3();
+ public static java.lang.Long[] pArrays2(org.jooq.Configuration configuration, java.lang.Long[] inArray) {
+ org.jooq.test.postgres.generatedclasses.routines.PArrays2 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays2();
p.setInArray(inArray);
p.execute(configuration);
diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/routines/FSearchBook.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/routines/FSearchBook.java
new file mode 100644
index 0000000000..9f8b45a320
--- /dev/null
+++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/routines/FSearchBook.java
@@ -0,0 +1,87 @@
+/**
+ * This class is generated by jOOQ
+ */
+package org.jooq.test.postgres.generatedclasses.routines;
+
+/**
+ * This class is generated by jOOQ.
+ */
+@java.lang.SuppressWarnings("all")
+public class FSearchBook extends org.jooq.impl.AbstractRoutine {
+
+ private static final long serialVersionUID = 1182854928;
+
+ /**
+ * The parameter public.f_search_book.RETURN_VALUE.
+ */
+ public static final org.jooq.Parameter RETURN_VALUE = createParameter("RETURN_VALUE", org.jooq.impl.DefaultDataType.getDefaultDataType("USER-DEFINED"));
+
+ /**
+ * The parameter public.f_search_book.p_title.
+ */
+ public static final org.jooq.Parameter P_TITLE = createParameter("p_title", org.jooq.impl.SQLDataType.VARCHAR);
+
+ /**
+ * The parameter public.f_search_book.p_limit.
+ */
+ public static final org.jooq.Parameter P_LIMIT = createParameter("p_limit", org.jooq.impl.SQLDataType.BIGINT);
+
+ /**
+ * The parameter public.f_search_book.p_offset.
+ */
+ public static final org.jooq.Parameter P_OFFSET = createParameter("p_offset", org.jooq.impl.SQLDataType.BIGINT);
+
+ /**
+ * Create a new routine call instance
+ */
+ public FSearchBook() {
+ super("f_search_book", org.jooq.test.postgres.generatedclasses.Public.PUBLIC, org.jooq.impl.DefaultDataType.getDefaultDataType("USER-DEFINED"));
+
+ setReturnParameter(RETURN_VALUE);
+ addInParameter(P_TITLE);
+ addInParameter(P_LIMIT);
+ addInParameter(P_OFFSET);
+ }
+
+ /**
+ * Set the p_title parameter IN value to the routine
+ */
+ public void setPTitle(java.lang.String value) {
+ setValue(org.jooq.test.postgres.generatedclasses.routines.FSearchBook.P_TITLE, value);
+ }
+
+ /**
+ * Set the p_title parameter to the function to be used with a {@link org.jooq.Select} statement
+ */
+ public void setPTitle(org.jooq.Field field) {
+ setField(P_TITLE, field);
+ }
+
+ /**
+ * Set the p_limit parameter IN value to the routine
+ */
+ public void setPLimit(java.lang.Long value) {
+ setValue(org.jooq.test.postgres.generatedclasses.routines.FSearchBook.P_LIMIT, value);
+ }
+
+ /**
+ * Set the p_limit parameter to the function to be used with a {@link org.jooq.Select} statement
+ */
+ public void setPLimit(org.jooq.Field field) {
+ setField(P_LIMIT, field);
+ }
+
+ /**
+ * Set the p_offset parameter IN value to the routine
+ */
+ public void setPOffset(java.lang.Long value) {
+ setValue(org.jooq.test.postgres.generatedclasses.routines.FSearchBook.P_OFFSET, value);
+ }
+
+ /**
+ * Set the p_offset parameter to the function to be used with a {@link org.jooq.Select} statement
+ */
+ public void setPOffset(org.jooq.Field field) {
+ setField(P_OFFSET, field);
+ }
+}