[[Property:title|Esql Sample]]
[[Property:weight|0]]
[[Property:uuid|04d03117-fdb2-8b73-677f-9b1a0c333dc4]]
This sample consists of a command line SQL parser. SQL statements are filtered through a monitor and sent to the RDBMS. 

==Compiling==

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

==Running==

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 enter standard SQL queries to interact with your database, for instance: 
<code>
SQL> select firstname, lastname from CONTACTS where lastname = 'Smith'
John    Smith
SQL>
				</code>

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

==Under the Hood==

This sample showcases the use of the 3 basic classes to interact with your database: 
*  [[ref:libraries/store/reference/db_control_chart|DB_CONTROL]]  to connect and disconnect to your database. 
*  [[ref:libraries/store/reference/db_selection_chart|DB_SELECTION]]  to perform 'select' queries. 
*  [[ref:libraries/store/reference/db_change_chart|DB_CHANGE]]  to perform SQL queries that output no result. 

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






