SELECT SQL statement
Description
Selects a row in the tables specified in RestOfSelectStatement.
Syntax
|
1 |
SELECT <span>RestOfSelectStatement</span> <br> {USING <span>TransactionObject</span>} ; |
|
Parameter |
Description |
|---|---|
|
RestOfSelectStatement |
The rest of the SELECT statement |
|
TransactionObject |
The name of the transaction object that |
Usage
An error occurs if the SELECT statement
returns more than one row.
Error handling
It is good practice to test the success/failure code
after executing a SELECT statement. You can test SQLCode for a failure code.
When you use the INTO clause, PowerBuilder
does not verify whether the datatype of the retrieved column matches
the datatype of the host variable; it only checks for the existence
of the columns and tables. You are responsible for checking that
the datatypes match. Keep in mind that not all database datatypes
are the same as PowerBuilder datatypes.
Examples
The following statements select data in the Emp_LName and Emp_FName columns
of a row in the Employee table and put the
data into the SingleLineEdits sle_LName and sle_FName (the
transaction object Emp_tran is used):
|
1 |
int   Emp_num |
|
1 |
string  Emp_lname, Emp_fname |
|
1 |
Emp_num = Integer(sle_Emp_Num.Text) |
|
1 |
|
1 |
SELECT employee.Emp_LName, employee.Emp_FName |
|
1 |
INTO :Emp_lname, :Emp_fname |
|
1 |
FROM Employee |
|
1 |
WHERE Employee.Emp_nbr = :Emp_num |
|
1 |
USING Emp_tran ; |
|
1 |
|
1 |
IF Emp_tran.SQLCode = 100 THEN |
|
1 |
MessageBox("Employee Inquiry", & |
|
1 |
"Employee Not Found") |
|
1 |
ELSEIF Emp_tran.SQLCode > 0 then |
|
1 |
MessageBox("Database Error", & |
|
1 |
Emp_tran.SQLErrText, Exclamation!) |
|
1 |
END IF |
|
1 |
sle_Lname.text = Emp_lname |
|
1 |
sle_Fname.text = Emp_fname |