java - Returning a list of output parameters from an Oracle Stored Procedure using JOOQ -


as output of oracle stored procedure, want return list of ids output parameter java code using jooq. number of id elements can vary. how can using jooq , how should pl/sql procedure coded accomplish this.

there many ways return sets / tables / arrays / cursors in oracle. i'd prefer following although other approaches equally supported jooq:

create type ids table of number(18); / create or replace function get_ids return ids    v_result ids; begin   select cast(collect(id) ids)   v_result   t_book;    return v_result; end get_ids; / 

the relevant generated jooq classes similar these:

public class getids extends abstractroutine<idsrecord> {     // ... }  public class idsrecord extends arrayrecordimpl<long> {     // ... }  public class routines {      // standalone calls     public static idsrecord getids(configuration configuration) {     }      // embedded calls     public static field<idsrecord> getids() {     } } 

you can either use standalone call such:

routines.getids(configuration).foreach(system.out::println); 

this yields number values directly

1 2 3 4 

or, embed function using dsl.table() operator

dsl.using(configuration)    .selectfrom(table(routines.getids()))    .fetch()    .foreach(system.out::println); 

this yields individual records

+------------+ |column_value| +------------+ |           1| +------------+ +------------+ |column_value| +------------+ |           2| +------------+ +------------+ |column_value| +------------+ |           3| +------------+ +------------+ |column_value| +------------+ |           4| +------------+ 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -