Selects a row in the tables specified in RestOfSelectStatement.
SELECT RestOfSelectStatement {USING TransactionObject} ;
Parameter |
Description |
---|---|
RestOfSelectStatement |
The rest of the SELECT statement (the column list INTO, FROM, WHERE, and other clauses). |
TransactionObject |
The name of the transaction object that identifies the database containing the table. This clause is required only for transaction objects other than the default (SQLCA). |
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.
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):
int Emp_num
string Emp_lname, Emp_fname
Emp_num = Integer(sle_Emp_Num.Text)
SELECT employee.Emp_LName, employee.Emp_FName
INTO :Emp_lname, :Emp_fname
FROM Employee
WHERE Employee.Emp_nbr = :Emp_num
USING Emp_tran ;
IF Emp_tran.SQLCode = 100 THEN
MessageBox("Employee Inquiry", &
"Employee Not Found")
ELSEIF Emp_tran.SQLCode > 0 then
MessageBox("Database Error", &
Emp_tran.SQLErrText, Exclamation!)
END IF
sle_Lname.text = Emp_lname
sle_Fname.text = Emp_fname