Examples—Select Statement
Select information about an employee based on the value in the empnum field. Then use the commit statement to end the transaction:
select last as lname, first as fname
from personnel
where empnum = :empnum;
commit;
Select rows for all employees with an employee number greater than 100, then use the commit statement to end the transaction. The table name is held in a variable:
tbl = 'employee';
select last as lname, first as fname,
employee as empnum
from :tbl
where number >100;
commit;
Read into the emptable array all projects for the employee whose number is currently displayed in the empnum field, then use the commit statement to end the transaction:
i = 1;
repeated select project as emptable[i].project,
hours as emptable[i].hours
from projects
where empnum = :empnum
begin
i = i + 1;
end
commit;
Retrieve the name and salary and set a variable to indicate the status of the salary:
i = 1;
select name as name, salary as salary
from emptable
begin
if salary > 100000 then
overpaid = TRUE;
else
overpaid = FALSE;
endif;
emptable[i].name = name;
emptable[i].salary = salary;
emptable[i].overpaid = overpaid;
i = i + 1;
end