ODBC Sample Programs

This page provides a set of ODBC sample programs that demonstrate how to work with Oracle TimesTen In-Memory Database and Oracle TimesTen Application-Tier Database Cache (TimesTen Cache).

The following ODBC sample programs are available in the quickstart/sample_code/odbc directory.

  Program Description
This program implements and measures time needed to insert many rows into a table. Parameters allow you to specify whether there are indexes on the table and whether statistics should be computed after doing the inserts. You can also specify insertion of the rows in batches to achieve better performance.
This sample program uses ODBC to access common PL/SQL packages (emp_pkg and sample_pkg) in four different ways:

- Calls a stored procedure with IN and OUT parameters
- Calls a stored function with IN and OUT parameters
- Calls an anonymous block and passes host variables into and out of the block
- Calls a store procedure to open a ref cursor and uses ODBC to process the result-set of the ref cursor

The EMP table and the emp_pkg and sample_pkg PL/SQL packages need to exist for this program to work.
This program implements a TPCB-like workload benchmark. The code populates the ACCOUNTS, BRANCHES, and TELLERS tables. It then executes a modified version of the TPCB benchmark, performing 25,000 transactions.

Each transaction updates the balance in the ACCOUNTS, BRANCHES and TELLERS tables, fetches the new balance from the ACCOUNTS table, and appends a record to the HISTORY table. At termination, it prints the measured performance.
This program implements a multi-user throughput benchmark. By default, the transaction mix consists of 80% SELECT (read) transactions and 20% UPDATE (write) transactions. In addition to SELECTs and UPDATEs, INSERTs can also be included in the transaction mix. The ratio of SELECTs, UPDATEs and INSERTs is specified at the command line. Each transaction consists of one or more SQL operations.

The benchmark initially populates the data store, and then executes the transaction mix on it. The number of rows inserted as part of the transaction mix cannot exceed the number of rows with which the database is populated initially.

The measurement error for the benchmark is at most 2 seconds. This will be negligible at loads with a duration in excess of 200 seconds. A suggested load for the benchmark is one which lasts at least 600 seconds.

The schema for this test is described in the program source file tptbm.c.
This program implements and measures a subset of queries from the Wisconsin benchmark. It will run about 30 queries, the first batch without indexes and the second batch with indexes. When finished, a report of the response time per query is generated.
This particular ODBC sample program is available in the quickstart/sample_code/odbc/xla directory.

This program demonstrates the usage of the TimesTen Transaction Log API (XLA) for C developers using ODBC. This program requires a user with XLA privilege to subscribe to changes in the database.

This program subscribes to the table APPUSER.MYDATA in the sampledb_1122 database. If running the program without any parameters, the program uses the default xlauser (created in the build_sampledb script).

To generate changes to the APPUSER.MYDATA, use ttIsql to connect to sampledb_1122 under appuser. Then execute database transactions on MYDATA.

Compile and Run

Click here to learn how to compile and run the sample programs on your installed platform.

For more information on how to use ODBC to develop database programs for the TimesTen database, see the TimesTen C Developer's Guide.