Class RecordParameterDefaults
java.lang.Object
org.postgresql.pljava.example.annotation.RecordParameterDefaults
- All Implemented Interfaces:
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
ResultSetProvider.Large
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.postgresql.pljava.ResultSetProvider
assignRowValues
-
Method Details
-
paramDefaultsRecord
@Function(schema="javatest", out={"name text","pgtypename text","javaclass text","tostring text"}) public static 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
-
assignRowValues
- Specified by:
assignRowValues
in interfaceResultSetProvider
- Throws:
SQLException
-
close
- Specified by:
close
in interfaceResultSetProvider
- Throws:
SQLException
-