You can retrieve data from a USoft application and use it in Service Definer in Java code that is the Implementation of a Method. Data may be retrieved successfully in various ways.
You retrieve data by calling the sql() utility function. The format in which retrieved data becomes available to your Java code depends on the Java output class that you use for the return value of the sql() function.
This help topic discusses various Java output classes that you are allowed to use when calling sql() in various situations.
If you execute a SELECT statement with a single output column that maps to either a single-column primary key or a single-column secondary key, then you can predict that the statement always returns at most 1 result row containing 1 value. In this situation you can use, as Java output class,
•A Java primitive wrapper class such as String, Integer, Double. •java.math.BigDecimal (for number values). •java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp (for date/time values). •A structure defined in Service Definer with an @Entity annotation. Example
java.math.BigDecimal price = (java.math.BigDecimal)sql( java.math.BigDecimal.class, "GET_SCHEDULED_TOUR_COSTS", new Object[]{id});
|
If you execute a SELECT statement with multiple output columns and you pass values for all primary-key columns, or there is a secondary key and you pass values for all secondary-key columns, then you can predict that the statement always returns at most 1 result row with multiple values. In this situation you can use, as Java output class, a structure defined in Service Definer with an @Entity annotation to fetch all the columns.
Example
MyPersonNameStructure result = (MyPersonNameStructure)sql( MyPersonNameStructure.class, "GET_PERSON_NAMES" , new Object[]{ id } );
|
If you execute a SELECT statement with a single output column and the statement is a SELECT that potentially returns multiple rows, you can use, as Java output class:
•An array of java primitive wrapper classes such as String, Integer, Double. •java.math.BigDecimal (for number values). •java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp (for date/time values. •An array of structures defined in Service Definer with an @Entity annotation. Example
String[] reservations = (String[])sql( String[].class, "GET_SCHEDULED_TOUR_DESTINATIONS" );
|
If you execute a SELECT statement with multiple output columns and the statement is a SELECT that potentially returns multiple rows, you can use, as Java output class,
•An array of structures defined in Service Definer with an @Entity annotation. Example
MyReservationStructure[] reservations = ( MyReservationStructure[])sql( MyReservationStructure[].class, "GET_CURRENT_BOOKINGS" );
|
See also
sql()
|