Class RecordParameterDefaults
- java.lang.Object
-
- org.postgresql.pljava.example.annotation.RecordParameterDefaults
-
- All Implemented Interfaces:
org.postgresql.pljava.ResultSetProvider
public class RecordParameterDefaults extends Object implements org.postgresql.pljava.ResultSetProvider
Example demonstrating the use of aRECORD
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.
-
-
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.
-
-
-
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
-
assignRowValues
public boolean assignRowValues(ResultSet receiver, int currentRow) throws SQLException
- Specified by:
assignRowValues
in interfaceorg.postgresql.pljava.ResultSetProvider
- Throws:
SQLException
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceorg.postgresql.pljava.ResultSetProvider
- Throws:
SQLException
-
-