Embedded SQL statements
Embedded SQL statements can appear anywhere that Java™ statements can legally appear. SQL statements
must appear within curly braces, as follows:
#sql
{
INSERT INTO customer VALUES
( 101, "Ludwig", "Pauli", "All Sports Supplies",
"213 Erstwild Court", "", "Sunnyvale", "CA",
"94086", "408-789-8075"
)
};
You can use the SELECT...INTO statement to retrieve data into Java™ variables (host variables).
Host variables within SQL statements are designated by a preceding
colon ( : ). For example, the following query places values in the
variables customer_num, fname, lname, company, address1, address2, city, state, zipcode,
and phone:
#sql
{
SELECT * INTO :customer_num, :fname, :lname, :company,
:address1, :address2, :city, :state, :zipcode,
:phone
FROM customer
WHERE customer_num = 101
};
SQL statements are case insensitive and can be written in uppercase, lowercase, or mixed-case letters. Java™ statements are case sensitive (and so are host variables).
You use SELECT...INTO statements for queries that return a single record; for queries that return multiple rows (a result set), you use an iterator object, described in the next section.