fetchField
Executes the query and returns the first column of its single row.
How you declare T states whether a value has to be there at all, and it covers both ways one can be absent: no row matched, or a row matched carrying SQL NULL. Under a non-nullable T both raise REQUIRED_ATTRIBUTE_MISSING; under a nullable one both come back as null. Declare fetchField<String?>() for a lookup that is allowed to find nothing.
How many rows came back is a separate question, governed by the Strict suffix: this variant tolerates none, fetchFieldStrict insists on exactly one, and both reject more than one.
Return
The value, which is null only where T is itself nullable.
Parameters
Values for $1, $2, … in declaration order.
Type Parameters
The type the column is mapped to. Its nullability is the whole contract: T comes back as declared, so a non-nullable one is guaranteed non-null and never needs unwrapping.
Throws
INCORRECT_RESULT_SIZE if more than one row matched.
REQUIRED_ATTRIBUTE_MISSING if T is not nullable and no row matched, or the value was NULL.