Hi - 

I am trying to use JOOQ to generate code for an Oracle UDT with declared 
static functions. Oracle UDT static methods are similar to Java static 
methods, they are invoked on the type rather than an instance of the type. 
Here is the relevant snippet from the UDT. The generated Java code follows.


create or replace

type rating_t

/**

 * Holds a rating

 *

as object(

   office_id      varchar2(16),

   rating_spec_id varchar2(372),

   effective_date date,

   create_date    date,

   active_flag    varchar2(1),

   formula        varchar2(1000),

   native_units   varchar2(256),

   description    varchar2(256),

   rating_info    rating_ind_parameter_t,

   current_units  varchar2(1), -- 'D' = database, 'N' = native, other = 
don't know

   current_time   varchar2(2), -- 'D' = database, 'L' = native, other = 
don't know

   formula_tokens str_tab_t,

 

…

 

   static function get_rating_code(

      p_rating_spec_id in varchar2,

      p_effective_date in date     default null,

      p_match_date     in varchar2 default 'F',

      p_time_zone      in varchar2 default null,

      p_office_id      in varchar2 default null)

   return number


=============================

/**
 * This class is generated by jOOQ
 */
package db.oracle.udt.records;

/**
 * This class is generated by jOOQ.
 */
@javax.annotation.Generated(value    = {"http://www.jooq.org";, "2.4.0"},
                            comments = "This class is generated by jOOQ")
public class RatingTRecord extends 
org.jooq.impl.UDTRecordImpl<usace.cwms.db.oracle.udt.records.RatingTRecord> 
{

    private static final long serialVersionUID = 904973548;

...

    /**
     * Call CWMS_20.RATING_T.GET_RATING_CODE
     *
     * @param pRatingSpecId
     * @param pEffectiveDate
     * @param pMatchDate
     * @param pTimeZone
     * @param pOfficeId
     * @throws org.jooq.exception.DataAccessException if something went 
wrong executing the query
     */
    public java.math.BigDecimal getRatingCode(java.sql.Date pEffectiveDate, 
java.lang.String pMatchDate, java.lang.String pTimeZone, java.lang.String 
pOfficeId) {
        usace.cwms.db.oracle.udt.rating_t.GetRatingCode f = new 
usace.cwms.db.oracle.udt.rating_t.GetRatingCode();
*        f.setPRatingSpecId(this);
*        f.setPEffectiveDate(pEffectiveDate);
        f.setPMatchDate(pMatchDate);
        f.setPTimeZone(pTimeZone);
        f.setPOfficeId(pOfficeId);

        f.execute(getConfiguration());
        return f.getReturnValue();
    }


The setPRatingSpecId() method on 'f' should be passed a String 
('p_rating_spec_id 
in varchar2', as you can see in the UDT signature). There is no 'this' in 
the context of a static UDT function call.

Peter

Reply via email to