Class RecordParameterDefaults

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

    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.

    • 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(schema="javatest",
                  out={"name text","pgtypename text","javaclass text","tostring text"})
        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",
                  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