EDBC is the CloudWriter connection to ODBC-enabled databases. ODBC is the Microsoft-authored standard for application program interface to SQL RDBMSs.
ODBC, through the ODBC Datasource Manager, assigns to each RDBMS/database a unique datasource name. The user of the database need only know the name of the datasource - not the particulars of its location and the RDBMS that manages it.
EDBC interfaces to ODBC through a class called EDBCConnection. Operations on the database - retrieving and storing data, adding new tables and columns, and so forth, are implemented through member functions of an EDBCConnection object. Results of these operations are returned in the EDBCResult object.
EDBCConnection(string dsn);
EDBCConnection(string dsn, string username, string authentication);
The constructor takes the data source name as an argument. Since CloudWriter operates as a system process, the dsn must be a system dsn. Username and authentication (usually the password) are optional but must be supplied if the data source is password protected.
Example
c = new EDBCConnection("sampledb");
EDBCResult exec(string stmt);
Execute an SQL statement.
Example
rslt = c.exec("select lastname, firstname from employees");
EDBCResult tables(string catalog, string schema, string tablename, string tabletype)
Get table information.
EDBCResult columns(string catalog, string schema, string tablename, string tabletype)
Get table information.
The EDBCResult object contains results from a connection::exec call.
Public Members
int retcode;
This is the return code from ODBC. The desired value is SQL_OK. Other values (TBD)
int nrows;
The number of rows in the result set.
int ncolumns;
The number of columns in the result set.
array v;
This is an array of arrays of values. Values are stored column-wise. Thus you would normally access the results of a query with an expression like:
rslt.v[column][row]
array names;
An array of the names of the result columns.
table tv;
A table of arrays that contain column values. The key is the name of the column. This is a different way to access the results of a query. You could access the results with an expression like:
rslt.tv["lastname"][row]
Sample Program
main() { c = new EDBCConnection("ssaccess"); if (c.Exec("SELECT Column1, Column2, Column3 FROM Table1;")) { s = c.rslt; // result set n = s.names; // column names nrows = s.nrows; ncolumns = s.ncolumns; v = s.v; // values <$<table>$> // put out the column names <$<tr>$> for (i=0; i<n.size; ++i) { <$<td><?n[i]?></td>$> } <$</tr>$> for (row=0; row<nrows; ++row) { <$<tr>$> for (col=0; col<ncolumns; ++col) { if (0) <$<td><?v[col][row]?></td>$> else <$<td><?s.tv[n[col]][row]?></td>$> } <$</tr>$> } <$</table>$> } else { s = c.rslt; // result set rc = s.rc; // return code } }John Elkins (john@vermontdatabase.com) 26 Oct 2002