TQuery component in Delphi enables your applications to use SQL syntax to access data from the database like paradox,Oracle etc.
We perform the following steps to use the TQuery component .
1. Create the TQuery Component.This can be done either by dropping the component on top the designer or during the runtime
var Query1 : TQuery; Query1 := TQuery1.Create(nil);
2. Set the DatabaseName property of the TQuery to the one that we use.
3. Add the query to the component.The query can be one that produces resultset and that dont.This is added via the property SQL.Text property of the TQuery component .
Query1.SQL.Text := 'Select name from employeetable';
4. Open the Query .
Now that we have the resultset ,we set the datasource of the DBGrid bound to the Query1 .This displays the data in the Grid .
Note that the resultset returned by the TQuery component’s Query (select statement ) is currently “ReadOnly”,where the user cannot edit the data in the Grid that has this resultset bound to it .
This is where the RequestLive property comes in to picture and helps us to make the Resultset returned as editable .
When the RequestLive property is set to true,the results are live that works similar to the TTable component where the user can edit data and when posted will immediately be updated in the database .
The query ‘select name from employeetable’ worked fine when i used it for the Paradox database,But the same query with the oracleDB and the RequestLive set to true resulted in the error “Table/View does not exist.”
This can be resolved by changing the tablename and the column names in the query to the Uppercase letters .
Eg : Query1.SQL.Text := 'SELECT NAME FROM EMPLOYEETABLE';