# Returning a Single Value from a Database Control Method

This topic describes how to write methods that return a single value from the database. The example provided represents a SELECT statement that requests only a single field of a single row. The return value of the method should be an object or primitive of the appropriate type for that field’s data.

## Returning a Single Column

The following example assumes a Customers table in which the field custid, representing the customer ID, is the primary key. Given the customer ID, the method looks up a single customer name.

    /**
     * @jc:sql statement="SELECT name FROM customer WHERE custid={customerID}"
     */
    public String getCustomerName(int customerID);

In this example, the name field is of type VARCHAR, so the return value is declared as String. The method’s customerID parameter is of type int. When the SQL statement executes, this parameter is mapped to an appropriate numeric type accepted by the database. To learn more about these relationships, see Mapping Database Field Types to Java Types in the Database Control.

Related Topics

Database Control

Creating a New Database Control

Parameter Substitution in @jc:sql Statements

Returning a Single Row from a Database Control Method

Returning Multiple Rows from a Database Control Method