SELECT
SQL statement
Description
Selects a row in the tables specified in
RestOfSelectStatement.
Syntax
|
1 |
SELECT RestOfSelectStatement {USING TransactionObject} ; |
|
Parameter |
Description |
|---|---|
|
RestOfSelectStatement |
The rest of the SELECT statement (the column list |
|
TransactionObject |
The name of the transaction object that identifies |
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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 |