Class RecordParameterDefaults

  • All Implemented Interfaces:
    org.postgresql.pljava.ResultSetProvider

    @SQLAction(provides="paramtypeinfo type",
               install="CREATE TYPE javatest.paramtypeinfo AS ( name text, pgtypename text, javaclass text, tostring text)",
               remove="DROP TYPE javatest.paramtypeinfo")
    public class RecordParameterDefaults
    extends Object
    implements org.postgresql.pljava.ResultSetProvider
    Example demonstrating the use of a RECORD parameter as a way to supply an arbitrary sequence of named, typed parameters to a PL/Java function.

    Also tests the proper DDR generation of defaults for such parameters.

    This example relies on implementor tags reflecting the PostgreSQL version, set up in the ConditionalDDR example.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.postgresql.pljava.ResultSetProvider

        org.postgresql.pljava.ResultSetProvider.Large
    • Method Summary

      Modifier and Type Method Description
      boolean assignRowValues​(ResultSet receiver, int currentRow)  
      void close()  
      static String paramDefaultsNamedRow​(ResultSet userWithNum)
      Like paramDefaultsRecord but illustrating the use of a named row type with known structure, and supplying a default for the function parameter.
      static org.postgresql.pljava.ResultSetProvider paramDefaultsRecord​(ResultSet params)
      Return the names, types, and values of parameters supplied as a single anonymous RECORD type; the parameter is given an empty-record default, allowing it to be omitted in calls, or used with the named-parameter call syntax.
      • Methods inherited from interface org.postgresql.pljava.ResultSetProvider

        assignRowValues
    • Method Detail

      • paramDefaultsRecord

        @Function(requires="paramtypeinfo type",
                  schema="javatest",
                  implementor="postgresql_ge_80400",
                  type="javatest.paramtypeinfo")
        public static org.postgresql.pljava.ResultSetProvider paramDefaultsRecord​(@SQLType(defaultValue={})
                                                                                  ResultSet params)
                                                                           throws SQLException
        Return the names, types, and values of parameters supplied as a single anonymous RECORD type; the parameter is given an empty-record default, allowing it to be omitted in calls, or used with the named-parameter call syntax.

        For example, this function could be called as:

         SELECT (paramDefaultsRecord()).*;
        
        or as:
         SELECT (paramDefaultsRecord(params => s)).*
         FROM (SELECT 42 AS a, '42' AS b, 42.0 AS c) AS s;
        
        Throws:
        SQLException
      • paramDefaultsNamedRow

        @Function(requires="foobar tables",
                  implementor="postgresql_ge_80400",
                  schema="javatest")
        public static String paramDefaultsNamedRow​(@SQLType(value="javatest.foobar_2",defaultValue={"bob","42"})
                                                   ResultSet userWithNum)
                                            throws SQLException
        Like paramDefaultsRecord but illustrating the use of a named row type with known structure, and supplying a default for the function parameter.

         SELECT paramDefaultsNamedRow();
        
         SELECT paramDefaultsNamedRow(userWithNum => ('fred', 3.14));
        
        Throws:
        SQLException
      • close

        public void close()
                   throws SQLException
        Specified by:
        close in interface org.postgresql.pljava.ResultSetProvider
        Throws:
        SQLException