Login Register Actian.com  

Actian Community Wiki

Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox

Ingres Examples

From Ingres Community Wiki

Jump to: navigation, search

This page contains a list of code samples dealing with the Ingres Technologies. It will also include helpful DBA scripts and standalone utilities. For helpful articles, including integrating Ingres with other Technology see Articles. New to Ingres and looking for some workshops/tutorials see Workshops.

If you are a new contributor to this page and need help, take a look at Content Developer.

Contents


Code Example Repository

Language SVN URL Sub-topics
C/C++ http://code.ingres.com/samples/c/ Embedded SQL, ODBC and OpenAPI
Java http://code.ingres.com/samples/java/ Hibernate, OpenJPA, JBoss Seam
Microsoft .NET http://code.ingres.com/samples/dot_net/ C#, ODBC.NET, VB.NET
Microsoft Visual Basic http://code.ingres.com/samples/visual_basic/
OpenROAD http://code.ingres.com/samples/openroad/ Empire
Perl http://code.ingres.com/samples/perl/ DBD::Ingres, DBD::ODBC
PHP http://code.ingres.com/samples/php/ PECL ingres, Universal ODBC, PDO ODBC
Python http://code.ingres.com/samples/python/ ingresdbi, Django
Ruby http://code.ingres.com/samples/ruby/ ActiveRecord, Ruby on Rails
Shell Scripts http://code.ingres.com/samples/shell_scripts/ UNIX, VMS, Windows

Database Server Scripts

The following code samples demonstrate use of the Ingres DBMS



Community Provided Examples

Useful DBA Scripts and Standalone Utilities

DBA Script Description
Utility to check status of Ingres Servers on Windows ingstatus is a utility found on the Linux and UNIX platforms that gives an indication of the servers that are running in the instance.
Dynamic Playback Ingres Load testing tool which uses the output from SC930 trace to feed back into an Ingres database reproducing almost equivalent load.
Changing table structures A python script to generate an terminal monitor script to drop primary key constraints and create them as btree with base table structure.
Collecting Ingres QEP and LockTrace Information Using JDBC Illustrates how to get Ingres Query execution plan, lock_trace etc using Ingres SET statements from a Java application
Summarise output of auditdb - Unix shell script This script strips out extra verbosity from the auditdb output
Removing Ingres Sessions Using IMA Below is an IMA script which removes all sessions connected to an Ingres installation. This is useful to run before shutting down Ingres for example. It uses the procedure ima_remove_session which should already be defined in imadb. In order to run it successfully it should be run by a user with Security Administrator privilege. It creates a temporary file so you should also run it from a directory where you can create files.
Full SQL Query Tool This example is a complete application for executing arbitary SQL statements. It demonstrates dynamic cursors, query analysis, error handling, and dynamic data type handling.
SQL Lock Monitor Tool This example is a complete application for monitoring locks. It demonstrates the use of embedded SQL to query the imadb and continuously display results.
IngresErrlogAnalysis This script will give you date, dow, timeofday and month analysis of every message type and a few specialized analyses (eg tables, page, session, etc analysis for deadlocks and similar messages). Best to copy the errlog and run the script on a non-Production machine.
SQLScriptsforUnix This document describes basic techniques for executing SQL from Unix/Linux shell scripts using the Ingres line-mode terminal monitor.
CatchBigFiles This script will detect big files in the Ingres work directory and for each detection will record information.
Show sessions Unix and DOS scripts to provide a quick formatted summary of output from iimonitor
Find Foreign Keys ESQLC program to help uncover possible foreign keys in large schemas.
Another Terminal Monitor Different implementation for the Ingres Terminal Monitor.
Create quick temp table in Ingres Script to create quick temp table in Ingres and load it with N rows for some generic testing/development.
Create variable temp table in Ingres Script to create temp table in Ingres with N+1 varchar(8) columns and load it with N rows for some generic testing/development.


User Defined Functions (in Ingres terminology Object Management Extensions aka OME) Examples

OME Program Examples Description
OME_README Object Management Extension (OME) Framework README
OME base64() The base64() function converts a varbyte or nvarchar string into a sequence of characters taken from the 64 element set: 'A'-'Z', 'a'-'z', '0'-'9', '+' and '/'.
OME checksum() The checksum() function uses the openssl encryption routines to provide an md5sum (or md2sum or sha1sum) of an input string.
OME rand seq gen() The function returns the next integer in the random sequence. All positive values in the range of the input integer type will be returned before the sequence repeats.
OME regex() The Linux regex library can be utilised from within OME to provide a NORMAL function which allows grep like regular expressions to be executed on varchar or long varchar strings.
OME soundex dm() The standard Ingres soundex function is a typical Knuth coded version of the Russell soundex (circa 1918). The Daitch-Mokotoff soundex (circa 1980) is an upgraded soundex more suitable to larger databases.
OME unicode64() The unicode64() function will (much like OME_base64()) convert an input string of nvarchar or varbyte characters into a sequence drawn from the 64 element set 'A'-'Z', 'a'-'z', '0'-'9', '+' and '/'.
OME nysiis(), nysiis_o() The NYSIIS (New York State Identification and Intelligence System) soundex was developed in 1970. The NYSIIS soundex features an accuracy increaes of 2.7% over the traditional Russell Soundex, but is not as reliable as the Daitch-Mokotoff Soundex. Nonetheless it is a lot easier to use than the Daitch-Mokotoff soundex.

Embedded SQL Examples

Embedded SQL Program Examples Description
Row Producing Procedure ESQL/C Example A simple example showing how to call and process the output of a row producing procedure using ESQL/C. This example uses the get_airports procedure from the Ingres IFF demodb database.
Full SQL Query Tool This example is a complete application for executing arbitary SQL statements. It demonstrates dynamic cursors, query analysis, error handling, and dynamic data type handling.

Application Development

OpenROAD

The following code snippets demonstrate Ingres OpenROAD

Community Provided Examples

OpenROAD Program Samples/Snippets Description
Generic_Column-click_TableField_Sort This procedure will provide header-click multicolumn sorting for all tablefields in your application.
Compare two Components/Applications This code provide ability to compare two OpenROAD Components or Applications from two different databases or between database and VSS.
Serialize objects to XML This sample application demonstrates how to serialize objects into XML files (and how to create objects from such XML files) using the HashTable and XML classes introduced in OpenROAD 5.1.
Handle the Trace Window This sample will show how to manipulate (hide, change icon, etc.) OpenROAD's trace window using the Windows-API (3GL Procedures).

JDBC/Java

The following code samples demonstrate use of Java with Ingres using the Ingres JDBC Driver

Community Provided Examples

Java Program Examples Description
Simple Connect and SELECT Sample This code will connect to your local demodb database and retrieve all columns from table country.
Simple Java Example Accessing Ingres demodb This simple example shows how to connect to Ingres using the Ingres JDBC Driver and the Ingres demodb.
Manipulating SQL CLOB data with JDBC These simple examples shows how to manipulate CLOB data using the Ingres JDBC Driver.
Calling Stored Procedures These examples shows how to call an Ingres stored procedure using the Ingres JDBC Driver.
Collecting Ingres QEP and LockTrace Information Using JDBC Illustrates how to get Ingres Query execution plan, lock_trace etc using Ingres SET statements from a Java application
Using Java Property Resource Bundles Example of using Java property resource bundles to contain driver, URL, and other driver configuration settings outside the actual Java code.
Using Multiple Threads in JDBC Applications This program connects to a database and runs a simple query in a multi-threaded context. It can be used for stress testing.
Ingres Java Frequent Flyer Demo This is a demo program that uses the example of an simple airline reservation system.
Time Sheet Application This is a fully functional time tracking program.
Cafe Frequent Flyer Application This is a demo program that uses the example of an simple airline reservation system.
Using the JDBC driver with the Ingres 9.3 new feature table procedures This program creates a row-returning procedure, references the procedure in a SELECT query, and fetches the resulting result set.
JBossTools Seam Example Resources Source code and EAR module of the example application accompanying the the 'Developing Applications Using An Open Source Technology Stack' white paper.
JDBC Statement - general, non-parameterized statements - IngBat1.java Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of general, non-parameterized statements in JDBC batch execution.
JDBC PreparedStatement - prepared statement with parameter sets - IngBat2.java Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of prepared statement with parameter sets in JDBC batch execution.
JDBC CallableStatement - database procedure with parameter sets - IngBat3.java Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of database procedure with parameter sets in JDBC batch execution.
JDBC performance - IngBat0.java Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate JDBC performance of batch execution.

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.
Testing ODBC Decimal Precision Tests limits of Ingres decimals using supplied decimal string test data.
Report DB Procedure Parameters using ODBC Demonstrates SQLProcedureColumns() to report on the parameters of database procedures
Test SQLExtendedFetch Function Support was recently added for the ODBC function SQLExtendedFetch(). Although SQLExtendedFetch() has been deprecated by SQLFetchScroll(), some ODBC applications rely on SQLExtendedFetch().
Test KeySet Cursors in ODBC Ingres 9.2 added support for scrollable cursors other than forward. The ODBC Driver will add support for this feature beginning with Ingres 9.3. Here is a sample test program to test keyset cursors in the Ingres 9.3 ODBC Driver.
Test Scrollable Static Cursors in ODBC Ingres 9.2 added support for scrollable cursors other than forward. The ODBC Driver will add support for this feature beginning with Ingres 9.3. Here is a sample test program to test scrollable static cursors in the Ingres 9.3 ODBC Driver.
Test Result Set Metatdata with SQLColAttribute Tests use of SQLColAttribute() to return characteristics of a result set.
ODBC Connection Pooling Demonstrates programming of ODBC connection pooling. This applies to Windows, unixODBC and the Ingres ODBC CLI for Ingres 9.2 (Ingres 2006 r3) and later.
Test ODBC Booleans Demonstrates support for the new Ingres 10 boolean data type as SQL_C_BIT and SQL_BIT.
ODBC Bulk Inserts Recent enhancements to ODBC dramatically increase the performance of bulk inserts using parameter arrays. Customers have reported 200x or greater improvement. This example shows how to use parameter arrays using the typical 'column-wise' type of parameter binding.
ODBC Explicit Batch The ODBC driver recently added support for 'explicit' batches. Explicit batches execute two or more queries in a single call to SQLExecute() or SQLExecDirect(). Dynamic parameters are bound as if the query set was a single query. This example executes four queries in explicit batch. An example of dynamic parameter binding is included.

.NET

The following code samples demonstrate use of the Ingres .NET Data Provider.

Demo Applications

.NET Program Examples Description
Frequent Flyer Demo The initial implementation of the Frequent Flyer Demo was in Csharp. The CsharpFrequent Flyer application is a standalone Windows desktop application that uses System.Windows.* APIs that come with Windows OS for its GUI components and makes direct SQL queries to Ingres .NET DataProvider. It doesn't require any external libraries. Obviously, this application only runs on Windows. This application is provided under the demo directory of an Ingres installation if the .NET Data Provider and the demodb is installed.

Connections

.NET Program Examples Description
.NET - Connect to a database as current user This simple example shows how to connect to Ingres using the Ingres .NET Data Provider. The connection string defaults to Port=II7 and to the current user credentials.
.NET Provider for ODBC - Insert Strings into Varchar The String data type in .NET applications is Unicode based (UTF-16 encoding). This .NET Data Provider for ODBC (ODBC.NET) C# sample program demonstrates how to INSERT Strings into an Ingres varchar datatype.

Executing Queries

.NET Program Examples Description
.NET - DataReader This simple example shows how to access a stream of Ingres data using the IngresDataReader class of the Ingres .NET Data Provider.
.NET - EnlistTransaction and TransactionScope IngresConnection's EnlistTransaction( ) method enables the Ingres .NET Data Provider to interface to an explicit transaction programming model using the .NET Transaction class or to an implicit transaction programming model using the .NET TransactionScope class. The example demonstrates a coordinated commit between two databases within a distributed transaction. This support is in Ingres 9.3 and later.
Using the new Ingres 10 Boolean Data Type with .NET A sample C# program that displays usage of the new Ingres 10 Boolean Data Type with .NET.

DataSet

.NET Program Examples Description
.NET - DataSet This simple example shows how to access Ingres data and fill a DataSet using the IngresDataAdapter class of the Ingres .NET Data Provider.

IngresStoredProcedures

.NET Program Examples Description
.NET - IngresStoredProcedures This step-by-step article uses VB.NET and the IngresDataReader object to retrieve data from an Ingres stored procedure.
.NET - IngresStoredProcedures - Parameters This C# code fragment calls an Ingres stored procedure with Input and InputOutput parameters.
.NET - IngresStoredProcedures - ReturnValue This C# code fragment calls an Ingres stored procedure with ReturnValue, Input, and InputOutput parameters.
.NET - IngresStoredProcedures - Global Session Temporary Table This C# code fragment calls an Ingres stored procedure passing a session temporary table. The code then retrieves data from the table to verify that the stored procedure executed successfully.
.NET - IngresStoredProcedures - InfoMessageEventHandler This C# program accesses the MESSAGE data returned by an Ingres stored procedure. The data provider uses the IngresInfoMessageEventHandler to access the returned string and code.

PHP

The following code samples are extracted from the test suite used for testing the PECL Ingres extension.

Connections

PHP Demo Program Description
PHP - Connect to a database as current user Connect to a database as current user
PHP - Connect to a database with user+password Connect to a database with user+password
PHP - Connect to a database using a role Connect to a database using a role
PHP - Connect to a database using a role and role password Connect to a database using a role and role password
PHP - Connect to a database changing the effective user Connect to a database changing the effective user
PHP - Connect to a database using a group Connect to a database using a group
PHP - Connecting with a dbms password Connecting with a dbms password

Executing Queries

PHP Demo Program Description
PHP - Execute a simple select against default link - no results returned Execute a simple select against default link - no results returned
PHP - Execute a simple select against default link - fetch object Execute a simple select against default link - fetch object
PHP - Execute a simple select against default link - fetch row Execute a simple select against default link - fetch row
PHP - Execute a simple select against default link - fetch assoc array Execute a simple select against default link - fetch assoc array
PHP - Nested (Master Detail) query Nested (Master Detail) query
PHP - Connect to a database using a group Connect to a database using a group
PHP - Connecting with a dbms password Connecting with a dbms password

Executing Queries With Parameters

PHP Demo Program Description
PHP - Execute a simple select using a parameter - fetch object Execute a simple select using a parameter - fetch object
PHP - Execute an insert using a parameter Execute an insert using a parameter
PHP - Execute a delete using a parameter Execute a delete using a parameter
PHP - Execute an update using a parameter Execute an update using a parameter

Modifying The Default Table And Index Structures

PHP Demo Program Description
PHP - Specifying the default structure for a newly created table Specifying the default structure for a newly created table
PHP - Specifying the default structure for a new index Specifying the default structure for a new index

Adjusting The Timezone and Date Format

PHP Demo Program Description
PHP - Adjust the timezone to GMT and retrieve a date value Adjust the timezone to GMT and retrieve a date value
PHP - Adjust the timezone to NA-PACIFIC and retrieve a date value Adjust the timezone to NA-PACIFIC and retrieve a date value
PHP - Adjust the timezone to NA-EASTERN and retrieve a date value Adjust the timezone to NA-EASTERN and retrieve a date value
PHP - Adjust the timezone to UNITED-KINGDOM and retrieve a date value Adjust the timezone to UNITED-KINGDOM and retrieve a date value
PHP - Adjust the timezone to HONG-KONG and retrieve a date value Adjust the timezone to HONG-KONG and retrieve a date value
PHP - Adjust the timezone to GMT-5 and retrieve a date value Adjust the timezone to GMT-5 and retrieve a date value
PHP - Adjust the timezone to GMT3-AND-HALF and retrieve a date value Adjust the timezone to GMT3-AND-HALF and retrieve a date value
PHP - Adjust the date format to US and retrieve a date value Adjust the date format to US and retrieve a date value
PHP - Adjust the date format to US and retrieve a date value Adjust the date format to US and retrieve a date value
PHP - Adjust the date format to MULTINATIONAL and retrieve a date value Adjust the date format to MULTINATIONAL and retrieve a date value
PHP - Adjust the date format to MULTINATIONAL4 and retrieve a date value Adjust the date format to MULTINATIONAL4 and retrieve a date value
PHP - Adjust the date format to GERMAN and retrieve a date value Adjust the date format to GERMAN and retrieve a date value
PHP - Adjust the date format to ISO and retrieve a date value Adjust the date format to ISO and retrieve a date value
PHP - Adjust the date format to ISO4 and retrieve a date value Adjust the date format to ISO4 and retrieve a date value
PHP - Adjust the date format to FINNISH and retrieve a date value Adjust the date format to FINNISH and retrieve a date value
PHP - Adjust the date format to DMY and retrieve a date value Adjust the date format to DMY and retrieve a date value
PHP - Adjust the date format to YMD and retrieve a date value Adjust the date format to YMD and retrieve a date value
PHP - Adjust the date format to MDY and retrieve a date value Adjust the date format to MDY and retrieve a date value
PHP - Date century boundary Date century boundary

Adjusting The Money Format And Currency Position

PHP Demo Program Description
PHP - Setting money format on connection Setting money format on connection
PHP - Setting money format to € in the trailing position Setting money format to € in the trailing position

Unicode

PHP Demo Program Description
PHP - Selecting Unicode data using NCHAR parameters Selecting Unicode data using NCHAR parameters
PHP - Executing a row producing procedure using NCHAR parameters Executing a row producing procedure using NCHAR parameters

BLOBS

PHP Demo Program Description
PHP - Selecting and Inserting a binary object Selecting and Inserting a binary object

Python

The following code samples demonstrate use of the Ingres Python Driver

Connections

Python Connect Example Simple Connection example to generate list of tables and their owners

Executing Queries

Changing Table Structures A python script to generate an terminal monitor script to drop primary key constraints and create them as btree with base table structure.
Simple Python Example for Selects Simple python script to demo how easy selects are in Python and DBI
Retrieval and use of Row Description The folllowing example demonstrates the use retrieval and use of the row description
Parsing a JDBC log and extracting the queries and timestamps A python script example of parsing a JDBC log and extracting the queries and timestamps. Also attempts to insert the values into an Ingres table.

Ruby

Ruby Program Examples Description
Flight Planner Demo Application The Ingres Ruby Frequent Flyer demo is a stand alone application that uses the TK GUI controls via RubyTK bindings to provide the visual interface with the Ingres Ruby driver used to connect to the demodb database.

OpenAPI

The following code samples demonstrate use of 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 9.2 the row count can be obtained using scrollable cursors.
Using Describe Input Demonstrates using IIapi_setDescriptor( ) and IIapi_putParams( ).
Searched timestamp queries Shows the use of timestamps as dynamic parameters for insert and searched fetch queries.
Searched Update timestamp queries Shows the use of timestamps as dynamic parameters for insert, fetch and update queries.
Batch Fetching using OpenAPI Fetching more than one row at a time improves the performance of an application by reducing traffic to/from the server
OpenAPI query literals - Apibatch0.c Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of OpenAPI query literals with batch execution.
OpenAPI parameterized queries - Apibatch1.c Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of OpenAPI parameterized queries with batch execution.
OpenAPI prepared queries - Apibatch2.c Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of OpenAPI prepared queries with batch execution.
OpenAPI database procedures - Apibatch3.c Ingres 10 will add full support for Batch Execution. This program is a test program to demonstrate the use of OpenAPI database procedures with batch execution.

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:

  • PAUSE Pause some number of seconds.
  • RAISE Call IIapi_query() to raise a database event.
  • INFO Call IIapi_getQueryInfo() to check raise event status.
  • CLOSE Call IIapi_close() to close request statement handle.
  • DONE Check if all events raised (done) or continue with PAUSE.
apiautil.c OpenAPI asynchronous demo utility module.

This module provides routine to perform common API calls synchronously.

The following functions are provided:

  • IIdemo_conn() Call IIapi_connect().
  • IIdemo_disconn() Call IIapi_disconnect().
  • IIdemo_abort() Call IIapi_abort().
  • IIdemo_autocommit() Call IIapi_autocommit().
  • IIdemo_query() Call IIapi_{query, getQueryInfo, close}().
  • IIdemo_checkError() Print API call status and error information.
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()

  • Register distributed transaction ID.
  • Prepare distributed transaction to be committed.
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()

  • Register distributed transaction ID.
  • Establish connection with distributed transaction.
  • Rollback distributed transaction.
  • Release distributed transaction ID.
apisauto.c Demonstrates using IIapi_autocommit().

Following actions are demonstrate in the main()

    • Enable autocommit
    • Disable autocommit
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()

  • Set EnvParam for segment length
  • Issue query
  • Get query result descriptors
  • Get query results
  • Close query processing
  • Free query resources.
apiscdel.c Demonstrates using IIapi_query(), IIapi_setDescriptor() and IIapi_putParams() to do a cursor positioned delete.

Following actions are demonstrated in the main()

  • Open cursor
  • Position cursor on row
  • Issue cursor delete statement
  • Describe parameters
  • Send parameter values
  • Get delete statement results
  • Free delete statement resources
  • Get cursor results
  • Free cursor resources
apiscomm.c Demonstrates using IIapi_commit()

Following actions are demonstrated in the main()

  • Commit transaction
apisconn.c Demonstrates using IIapi_connect(),IIapi_setConnectParam(), IIapi_disconnect() and IIapi_abort()

Following actions are demonstrate in the main()

  • Connect (no conn parms)
  • Disconnect
  • Set Connection Parameters
  • Connect (with conn parms)
  • Abort Connection
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()

  • Copy data from program into table.
  • Copy data into program from table.
apiscupd.c Demonstrates using IIapi_query(), IIapi_setDescriptor() and IIapi_putParams() to do a cursor positioned update.

Following actions are demonstrated in the main()

  • Open cursor
  • Position cursor on row
  • Issue cursor update statement
  • Describe parameters
  • Send parameter values
  • Get update statement results
  • Free update statement resources
  • Get cursor results
  • Free cursor resources
apisdata.c Demonstrates using IIapi_formatData() and IIapi_convertData()

Following actions are demonstrated in the main()

  • Set environment parameter
  • Convert string to DATE using environment date format.
  • Convert DATE to string using installation date format.
apiserr.c This demo program can be taken as an example of a generic error

handler function for handling OpenAPI errors returned to the application. Additionally please refer to the OpenAPI documentation, section "Generic Parameters" to understand the meaning of each of IIAPI_ST_* error codes returned in "gp_status" o/p parameter of IIAPI_GENPARM structure.

Demonstrates using IIapi_getQueryInfo() and IIapi_getErrorInfo().

Following actions are demonstrated in the main()

  • Check status of statement with no rows.
  • Check status of insert statement.
  • Check status of invalid statement.
apisinit.c Demonstrates using IIapi_init(),IIapi_setEnvParam(), IIapi_releaseEnv() and IIapi_term()

Following actions are demonstrate in the main()

  • Initialize at level 1
  • Terminate API
  • Initialize at level 2
  • Set environment parameter
  • Release environmment resources
  • Terminate API
apisname.c Demonstrates using IIapi_connect(), IIapi_autocommit() and IIapi_query() to access the Name Server database.

Following actions are demonstrate in the main()

  • Connect to local Name Server
  • Enable Autocommit
  • Query connection info
  • Disable autocommit
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()

  • Create procedure
  • Execute procedure
  • Retrieve BYREF parameter results
  • Get procedure results
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()

  • Create procedure
  • Execute procedure
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()

  • Create procedure
  • Execute procedure
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()

  • Create procedure
  • Execute procedure
  • Retrieve result rows
  • Get procedure results
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()

  • Define repeated insert.
  • Execute repeated insert.
apisroll.c Demonstrates using IIapi_savePoint() and IIapi_rollback()

Following actions are demonstrated in the main()

  • Create savepoint
  • Rollback to savepoint
  • Rollback transaction.
apisscrl.c Demonstrates using IIapi_scroll() and IIapi_position().

Scroll and position in a result set.

Following actions are demonstrated in the main()

  • Issue query
  • Get query result descriptors
  • Scroll/position cursor
  • Get query results
  • Free query resources
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()

  • Issue query
  • Get query result descriptors
  • Get query results
  • Cancel query processing
  • Free query resources.
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()

  • Issue query
  • Get query result descriptors
  • Get query results
  • Cancel query processing
  • Free query resources.
Personal tools
© 2011 Actian Corporation. All Rights Reserved