Sample program for  aodbc-1.0


Tips for installation and things to change:

The program creates the table XYZXYZ:
 
name of column data-type
NAME CHAR(50)
TELEFON CHAR(50)
Table 1: structure of table XYZXYZ

Then you can insert records into it.

Finally the program selects everything from XYZXYZ and prints it out.

To compile it, you should use the provided Makefile. You must have set the environment for adabas (DBROOT & PATH). You can do this by executing the following: 

. profile


// Sample for use of aodbc-1.0
//
// (c) 1997 js

#include <stdio.h>
#include <string.h>
#include "database.h"
#include "collection.h"
#include "util.h"

main()
{
    char    buffer[255];
    char    name[50];
    char    tel[50];

    openlog("test.log");

    tDatabase *database = new tDatabase("dbnode:dbname", "user", "pwd");
    tDataSource *query;

    // open connection to database
    database->open();

    query = new tDataSource(database);

    sprintf(buffer, "create table XYZXYZ (name char(50), telefon char(50))");
    query->ExecSQL(buffer);
    query->reset();

    printf("enter name/tel, use name=quit to exit...\n\n");

    do {
        printf("enter name: ");
        scanf("%s", name);
        printf("enter tel :");
        scanf("%s", tel);

        if(strcmp(name, "quit"))
        {
            sprintf(buffer, "insert into XYZXYZ values ('%s', '%s')",
                name,
                tel
            );
            query->ExecSQL(buffer);
            query->reset();
        }
    } while(strcmp(name, "quit"));

    // now select everything

    printf("select all...\n");

    sprintf(buffer, "select * from XYZXYZ");
    query->ExecSQL(buffer);

    printf("%50s %50s\n\n", "Name", "Telefon");

    for(int i=0; i<query->getRowCount(); i++)
    {
        printf("%50s %50s\n",
            query->getRow(i)->Get(0),
            query->getRow(i)->Get(1)
        );
    }

    delete query;
    delete database;

    closelog();
}