[[Property:title|Selector Sample]]
[[Property:weight|1]]
[[Property:uuid|3d608710-5537-04e4-fa89-a608ee6864cd]]
This sample creates a <eiffel>DB_BOOK</eiffel> table in your database, enters sample data in it and lets you select rows from this table with author's name. 

==Compiling==

To compile the example: 
* Launch EiffelStudio. 
* Click '''Add project'''
* Browse to ''$ISE_EIFFEL\examples\store\select\''. 
* Clicking open loads the selected project
* Choose select.ecf
* Select the target according to the installed DBMS
* Choose the location where the project will be compiled, by default the same directory containing the configuration file. 
* Click '''OK'''. 

==Running==

Before running this sample, one must do link a specific file to data.sql as follows: 

With Oracle: 

''ln data.sql.oracle data.sql'' 

With ODBC: 

''ln data.sql.odbc data.sql'' 

{{caution|The ''data.sql'' file must be available in the sample application current directory. If you run the sample from EiffelStudio, this directory should be the ''EIFGENs/target/W_CODE/'' directory of your project (where target is one of the installed DBMS). }}

This sample lets you interact with your database through a console. 

First you have to enter the database connection information: 
* For ODBC: 
<code>
Database user authentication:
Data Source Name: handson
Name: smith
Password: mypass
					</code>

{{note|''Name'' and ''Password'' are not required with ODBC. If you don't need ''Name'' and ''Password'', you can simply hit ''Return'' when prompted. }}

* For Oracle: 
<code>
Database user authentication:
Name: smith@HANDSON
Password: mypass
					</code>

{{note|You must specify the Oracle User Name and Net Service Name with the syntax ''<user>@<service> ''where ''<user>'' stands for the User Name and ''<service>'' stands for the Net Service Name. }}


Then you can select rows from this table with author's name, for instance: 
<code>
Author? ('exit' to terminate):Bertrand Meyer
Seeking for books whose author's name match: Bertrand Meyer

Author:Bertrand Meyer
Title:Eiffel The Libraries
Quantity:11
Price:20
double_value:435.60000610351562
First publication:07/01/1994 12:00:00.0 AM


Author:Bertrand Meyer
Title:Eiffel The Language
Quantity:9
Price:51
double_value:775.22998046875
First publication:07/01/1992 12:00:00.0 AM



Author? ('exit' to terminate):
				</code>

{{note|Enter ''exit'' to quit the application. }}

==Under the Hood==

This sample showcases the use of the [[ref:libraries/store/reference/db_selection_chart|DB_SELECTION]]  class to perform smart ''select'' queries, using: 
*  [[Data Object Coupling|Database data and Eiffel objects Coupling]] . 
*  [[Query variables|Variables Binding]] . 

The whole sample code is contained in the root class:
*  SELECTOR for Oracle. 
*  SELECTOR_ODBC for ODBC. 






