[[Property:title|Inserter Sample]]
[[Property:weight|2]]
[[Property:uuid|fa0b8601-ca7a-b1cc-384d-f366be33ac40]]
This sample lets the user insert a DB_BOOK object in your database using EiffelStore insertion facilities. 

==Compiling==

To compile the example: 
* Launch EiffelStudio. 
* Click '''Add project'''
* Browse to ''$ISE_EIFFEL\examples\store\insert\''. 
* Clicking open loads the selected project
* Choose inserter.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==

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 insert a book in the database, for instance: 
<code>
What new book should I create?

Author? John Smith

Title? My book

Quantity? 1

Price? 50

Year? 2001

Double value? 12.675

Object inserted
</code>

{{note|If your database does not contain a <eiffel>DB_BOOK</eiffel> table, this example will create it. }}

==Under the Hood==

This sample showcases the use of the [[ref:libraries/store/reference/db_store_chart|DB_STORE]]  class to [[Data Object Coupling| perform database insertions]]  where the SQL language is totally abstracted. 

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






