Hello,

You're almost there!

Replace this:

String sql = "SELECT get_test(1)";


With this:

String sql = "SELECT * FROM get_test(1)";


The rest of the code should be the same.

Cheers
Lukas

2015-01-16 17:25 GMT+01:00 <[email protected]>:

> Hi.
>
> Because of previously discussed limits of JOOQ, I'm trying to find a way
> to use some parts of JOOQ in order to use a SETOF-returning-function:
>
> Here is the PostgreSQL part:
>
> test=> \d test
>                           Table "public.test"
> ┌────────┬─────────┬───────────────────────────────────────────────────┐
> │ Column │  Type   │                     Modifiers                     │
> ├────────┼─────────┼───────────────────────────────────────────────────┤
> │ id     │ integer │ not null default nextval('test_id_seq'::regclass) │
> │ a      │ integer │                                                   │
> └────────┴─────────┴───────────────────────────────────────────────────┘
> Indexes:
>     "test_pkey" PRIMARY KEY, btree (id)
> Number of child tables: 2 (Use \d+ to list them.)
>
> test=> \sf get_test
> CREATE OR REPLACE FUNCTION public.get_test(id_p integer)
>  RETURNS SETOF test
>  LANGUAGE plpgsql
> AS $function$
> BEGIN
>     RETURN QUERY SELECT * FROM test WHERE id = id_p;
> END;
> $function$
>
> Here is something I'm trying to do:
>             String sql = "SELECT get_test(1)";
>             Result<Record> result = create.fetch(sql);
>
>             System.out.println(result);
>
>             for (Record r : result) {
>                 System.out.println(r);
>             }
>
>             List<TestRecord> l = result.into(TestRecord.class);
>
> The println part shows me something cool:
> +--------+
> |get_test|
> +--------+
> |(1,1)   |
> +--------+
>
> but I'm really not able to put these data in a POJO or in a Record: all
> fields of my TestRecord are remaining to NULL.
>
> Is there a way I could bind the returned data to the object I want to
> manipulate?
>
>
> Adrien.
>
>  --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to