Ingres Examples
From Ingres Community Wiki
This page contains a list of code samples dealing with the Ingres Technologies. For helpful articles, including integrating Ingres with other Technology see Tech Tips.
|
The following code samples demonstrate use of the Ingres DBMS
Community Provided Examples
Useful DBA Scripts
OME Examples
| OME Program Examples | Description |
|---|---|
| OME_README | |
| OME base64() | |
| OME checksum() | |
| OME rand seq gen() | |
| OME regex() | |
| OME soundex dm() | |
| OME unicode64() |
Embedded SQL Examples
| Embedded SQL Program Examples | Description |
|---|---|
| Row Producing Procedure ESQL/C Example |
Application Development
OpenROAD
JDBC
The following code samples demonstrate use of the Ingres JDBC Driver
Community Provided Examples
ODBC
The following code samples demonstrate use of the Ingres ODBC Driver
Community Provided Examples
| ODBC Program Examples | Description |
|---|---|
| Insert and Fetch of Blobs Using ODBC | Create a table containing a long varchar. Read an ASCII file and insert contents into the table. Fetch and display the result. |
| Simple Select Using ODBC | Select a column from the iitables catalog and display the result. |
| Getting Metadata Information about the ODBC Driver | Use SQLGetInfo() and SQLGetTypeInfo() to show information about the ODBC driver and supported data types. |
.NET
The following code samples demonstrate use of the Ingres .NET Data Provider.
Connections
| .NET Program Examples | Description |
|---|---|
| .NET - Connect to a database as current user | |
Executing Queries
| .NET Program Examples | Description |
|---|---|
| .NET - DataReader | |
DataSet
| .NET Program Examples | Description |
|---|---|
| .NET - DataSet | |
PHP
The following code samples are extracted from the test suite used for testing the PECL Ingres extension.
Connections
Executing Queries
Executing Queries With Parameters
Modifying The Default Table And Index Structures
| PHP Demo Program | Description |
|---|---|
| PHP - Specifying the default structure for a newly created table | |
| PHP - Specifying the default structure for a new index |
Adjusting The Timezone and Date Format
Adjusting The Money Format And Currency Position
| PHP Demo Program | Description |
|---|---|
| PHP - Setting money format on connection | |
| PHP - Setting money format to € in the trailing position |
Unicode
| PHP Demo Program | Description | |
|---|---|---|
| PHP - Selecting Unicode data using NCHAR parameters | ||
| PHP - Executing a row producing procedure using NCHAR parameters |
BLOBS
| PHP Demo Program | Description |
|---|---|
| PHP - Selecting a binary object | |
| PHP - Inserting a binary object |
Python
The following code samples demonstrate use of the Ingres Python Driver
Connections
Executing Queries
- Changing Table Structures
- Simple Python Example for Selects
- Retrieval and use of Row Description
- Parsing a JDBC log and extracting the queries and timestamps
Ruby
| Ruby Program Examples | Description |
|---|---|
OpenAPI
The following code samples demonstrate use of the Ingres OpenAPI.
Community Provided Examples
| API Demo Program | Description |
|---|---|
| Row count from a select query | Until IngreS 9.2.0 there was only one way to get the number of rows returned with a "SELECT" statement, using "IIapi_getQueryInfo()". Unfortunately if called before all the results are fetched from Ingres "IIapi_getQueryInfo()" will terminate any existing results still to be fetched. With Ingres 2006 release 3 the row count can be obtained using scrollable cursors. |
| Using Describe Input |
Examples Provided with the Ingres Distribution
Several synchronous and asynchronous OpenAPI examples are provided as part of the Ingres distribution. These examples are installed into the %II_SYSTEM%\ingres\demo\api directory. The examples are documented below:
| API Demo Program | Description | |
|---|---|---|
| apiademo.c | OpenAPI asynchronous demo main control module.
This program demonstrates calling OpenAPI asynchronously, using callback functions for notification of OpenAPI call completion and the processing of database events using OpenAPI. The program consist of four modules: a main control module (apiademo.c), a server module (apiasvr.c), a client module (apiaclnt.c) and a utility module (apiautil.c). The server module establishes a connection to the target database, creates a database event and registers to receive event notification. The server then waits for database events to be received. The client module establishes it's own database connection, raises a series of database events and terminates. The server terminates when a database event is received indicating that termination has been requested. The main control module processes the command line arguments and initializes, runs and terminates the client and server modules. The utility module provides common synchronous OpenAPI calls used during initialization and termination. The program can be run as a client, a server or both. Multiple clients and multiple servers may be run concurrently. | |
| apiasvr.c | OpenAPI asynchronous demo server module.
The server demo establishes a connection with the target database, creates and registers a database event and waits to receive event notifications. Server execution is implemented in a single processing function with a set of actions. Each action represents a state in a finite state machine. | |
| apiaclnt.c | OpenAPI asynchronous demo client module.
The client demo establishes a connection with the target database and raises database events at (somewhat) random intervals. Client execution is implemented as a series of callback functions. Each asynchronous OpenAPI request specifies the next sequential function as its callback. Each function represents a state in a simple finite state machine as follows:
| |
| apiautil.c | OpenAPI asynchronous demo utility module.
This module provides routine to perform common API calls synchronously. The following functions are provided:
| |
| apis2ph1.c | Demonstrates using IIapi_registerXID(), IIapi_prepareCommit().
First part of the two phase commit demo. Begin a distributed transaction and exit without disconnecting. Run apis2ph2 to finish processing of distributed transaction. Following actions are demonstrated in the main()
| |
| apis2ph2.c | Demonstrates using IIapi_registerXID(), IIapi_connect() with transaction handle, IIapi_releaseXID().
Second part of two phase commit demo. Run apis2ph1 to begin distributed transaction. Reconnects to distribute transaction and rolls back the transaction. Following actions are demonstrated in the main()
| |
| apisauto.c | Demonstrates using IIapi_autocommit().
Following actions are demonstrate in the main()
| |
| apisblob.c | Demonstrates using IIapi_setEnvParam(), IIapi_query(), IIapi_getDescriptor(), IIapi_getColumns(), IIapi_getQueryInfo(), and IIapi_close().
SELECT row with blob data. Following actions are demonstrated in the main()
| |
| apiscdel.c | Demonstrates using IIapi_query(), IIapi_setDescriptor() and IIapi_putParams() to do a cursor positioned delete.
Following actions are demonstrated in the main()
| |
| apiscomm.c | Demonstrates using IIapi_commit()
Following actions are demonstrated in the main()
| |
| apisconn.c | Demonstrates using IIapi_connect(),IIapi_setConnectParam(), IIapi_disconnect() and IIapi_abort()
Following actions are demonstrate in the main()
| |
| apiscopy.c | Demonstrates using IIapi_query(), IIapi_getCopyMap(), IIapi_putColumns() and IIapi_getColumns() to execute 'copy from' and 'copy into' statements.
Following actions are demonstrated in the main()
| |
| apiscupd.c | Demonstrates using IIapi_query(), IIapi_setDescriptor() and IIapi_putParams() to do a cursor positioned update.
Following actions are demonstrated in the main()
| |
| apisdata.c | Demonstrates using IIapi_formatData() and IIapi_convertData()
Following actions are demonstrated in the main()
| |
| apiserr.c | Demonstrates using IIapi_getQueryInfo() and IIapi_getErrorInfo().
Following actions are demonstrated in the main()
| |
| apisinit.c | Demonstrates using IIapi_init(),IIapi_setEnvParam(), IIapi_releaseEnv() and IIapi_term()
Following actions are demonstrate in the main()
| |
| apisname.c | Demonstrates using IIapi_connect(), IIapi_autocommit() and IIapi_query() to access the Name Server database.
Following actions are demonstrate in the main()
| |
| apisparm.c | Demonstrates using IIapi_setDescriptor() and IIapi_putParams(). | |
| apisprbr.c | Demonstrates using IIapi_query(), IIapi_setDescriptor(), IIapi_putParams(), IIapi_getDescriptor() and IIapi_getColumns() to execute a database procedure with BYREF parameters and retrieve the parameter result and procedure return values.
Following actions are demonstrated in the main()
| |
| apisprgt.c | Demonstrates using IIapi_query(), IIapi_setDescriptor() and IIapi_putParams() to execute a database procedure with a global temporary table parameter.
Following actions are demonstrated in the main()
| |
| apisproc.c | Demonstrates using IIapi_query(), IIapi_setDescriptor(), IIapi_putParams(), IIapi_getQInfo() and IIapi_close() to execute a database procedure.
Following actions are demonstrated in the main()
| |
| apisprrp.c | Demonstrates using IIapi_query(), IIapi_setDescriptor(), IIapi_putParams(), IIapi_getDescriptor() and IIapi_getColumns() to execute a database procedure which returns multiple rows.
Following actions are demonstrated in the main()
| |
| apisrept.c | Demonstrates using IIapi_query(), IIapi_setDescriptor() and IIapi_putParams() to define and execute a repeated statement.
Following actions are demonstrated in the main()
| |
| apisroll.c | Demonstrates using IIapi_savePoint() and IIapi_rollback()
Following actions are demonstrated in the main()
| |
| apisscrl.c | Demonstrates using IIapi_scroll() and IIapi_position().
Scroll and position in a result set. Following actions are demonstrated in the main()
| |
| apisselc.c | Demonstrates using IIapi_query(), IIapi_getDescriptor(), IIapi_getColumns() and IIapi_close().
SELECT data using a cursor. Following actions are demonstrated in the main()
| |
| apissell.c | Demonstrates using IIapi_query(), IIapi_getDescriptor(), IIapi_getColumns(), IIapi_cancel() and IIapi_close().
SELECT data using a select loop. Following actions are demonstrated in the main()
|
