Compile and Run ODP.NET Sample Program


IMPORTANT PRE-REQUISITES

1. Set up sample database and user accounts

The following build_sampledb script should be run once to set up the sample database and user accounts

Windows:   > cd quickstart\sample_scripts\createdb
> build_sampledb.bat

2. Set up environment to compile and run the sample programs

The following script must be run for each of the terminal session:

Windows:   > quickstart\ttquickstartenv.bat

How to compile the sample ODP.NET program

The ODP.NET sample program runs on Windows platforms only.

To compile the sample program in the sample_code\odp.net directory, perform the following steps in a .NET 2.x or 4.0 environment. Remember that for .NET 4.0 you must install Visual Studio 2010 and work in Visual Studio Command Prompt 2010.

To build a sample program in the sample_code/odp.net directory, open a Visual Studio Command Prompt then execute the following command:

[Windows] > csc /out:<program-name>.exe /reference:<path\to\Oracle.DataAccess.dll> <program-name>.cs
where <program-name> is the program you want to compile. The program must also reference the Oracle.DataAccess.dll assembly located in your ODP.NET installation.

For example, to compile the DemoODP program using ODP.NET, you do something like:

[Windows] > csc /out:DemoODP.exe  /reference:C:\path\Oracle.DataAccess.dll DemoODP.cs

 

How to run the sample ODP.NET program

  DemoODP This program illustrates the following functionality:
- Executing a plain SQL statement
- Executing a PLSQL block, using IN parameters
- Executing an SQL statement using IN parameters
- Array binding (batch insert)
- Executing a database procedure using IN and OUT parameters
- Using REF CURSOR

  Examples:

   (run the program specifying the default DSN sampledb_1122, username appuser and password)
  DemoODP -db sampledb_1122 -user appuser -passwd <mypassword>

   (run the program using the default DSN, username and password, and direct the output to a log file)
  DemoODP -db sampledb_1122 -user appuser -passwd <mypassword> -log test.out

  For full syntax of the program, try "DemoODP -help".

The expected test output looks similar to this:

Start Test
The employee who got the 10% pay raise was CLARK

Employees in department #50:
7944, ITMGR, MANAGER, 7839, 10/08/2010 10:34:20 AM, 2500, , 50
7945, DVLPR1, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7946, DVLPR2, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7947, DVLPR3, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7948, DVLPR4, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7949, DVLPR5, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7950, DVLPR6, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7951, DVLPR7, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7952, DVLPR8, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7953, DVLPR9, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
7954, DVLPR10, DEVELOPER, 7944, 10/08/2010 12:00:00 AM, 2000, , 50
Test finished

 

For more information on .NET programming with Oracle TimesTen, refer to the Oracle Data Provider for .NET TimesTen In-Memory Database Support User's Guide.