Write access to the data
We need to be able to run SQL insert and delete queries.
The following program works with the appropriate password edited in.
Demonstrates this requirement is fulfilled
{
char *cmds[] = {
"drop table t1",
"create table t1 ( c1 int, c2 float, c3 varchar(30))",
"insert into t1 values ( 1, 1.0, 'one')",
"insert into t1 values ( 2, 2.0, 'two')",
"insert into t1 values ( 3, 3.0, 'three')",
"delete from t1 where c1=2",
};
TSQLServer *db = TSQLServer::Connect("oracle://phoenix.fnal.gov:1521/test10.2","minos_dev","SUPER_DOUBLE_SECRET");
printf("connected: %s\n",db->ServerInfo());
int len = sizeof(cmds)/sizeof(cmds[0]);
for (int i=0; iQuery(cmds[i]);
delete res;
}
TSQLResult *res = db->Query("select * from t1");
int nrows = res->GetRowCount();
int nfields = res->GetFieldCount();
printf("table t1 has %d rows of %d fields\n",nrows,nfields);
for (int i=0; i < nrows; i++) {
TSQLRow *row = res->Next();
for (int j = 0; j < nfields; j++) {
printf("%s ", row->GetField(j));
}
printf("\n");
delete row;
}
delete res;
}
Produces following output:
CINT/ROOT C/C++ Interpreter version 5.16.11, April 14, 2006
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing root2.oracle.C...
connected: Oracle
executing drop table t1
executing create table t1 ( c1 int, c2 float, c3 varchar(30))
executing insert into t1 values ( 1, 1.0, 'one')
executing insert into t1 values ( 2, 2.0, 'two')
executing insert into t1 values ( 3, 3.0, 'three')
executing delete from t1 where c1=2
table t1 has 2 rows of 3 fields
1 1.000000 one
3 3.000000 three