Projects / libsqlora8

libsqlora8

libsqlora8 is a library that makes Oracle access for C programmers much easier than using Oracle's OCI interface. The library is built on top of OCI8 and simplifies some common tasks.

Tags
Licenses
Operating Systems
Implementation

RSS Recent releases

  •  14 Aug 2003 10:34

Release Notes: Major memory leak problems are fixed now.

  •  26 Aug 2002 15:15

Release Notes: Trying to execute non-SQL statements when running multiple threads could cause corruption of the internal memory structures. This has been fixed. Windows build instructions are included.

  •  25 Jul 2002 06:03

Release Notes: This version fixes a problem in the configure script, where the Oracle version couldn't be determined on several platforms.

Release Notes: A feature to register a signal handler for interrupts (SIGINT) was added. The usual bugfixes were made.

  •  12 Jun 2002 03:02

Release Notes: Small fixes for configuring and installing the package, and updated documentation.

RSS Recent comments

22 Jul 2003 07:40 yatos

Re: A little problem with sqlo_ocol_names and memory alloc size

Hello :

My name is Ignacio Holgado. Apologies for my english ( I am spanish ).
I am developping an aplication server with oracle support in a multithreaded environment in a SuSe O.S.
I have developped a "cursor object" in order to allow the access to a generic database from the aplications dispatched by my aplication server.
The first implementation of this cursor object was implemented using the "easy interface" but now I need some functionalities from the advanced interface
and i have 2 litle problems:

1 - My first problem is that i can't obtain the column names from the advanced interface. It seams that it don't works with the "advanced interface". Maybe i am not using it propertly. I have made a bad solution and i would like to have a better solution.
I use it with the following code :



...
*cursor = sqlo_prepare ( *connection, sql_stmt ); // runs OK
...
status = SQLexecute(cursor,0); // runs OK ( this is a wrapper to sqlo_execute )
...
result->n_ocols = sqlo_ncols(*cursor, 0); // returns the number of columns OK !!


for (type = SQLgetColType(cursor,i+1); (type>=0) && (i<=result->n_ocols);type = SQLgetColType(cursor,(++i)+1))
{
...
if (SQLO_SUCCESS != (status = sqlo_define_by_pos(*cursor, i+1, type, result->data[2*i], size, result->data[2*i+1],&(result->length[i]),0)))
{
....
....
}
}

...
status = SQLexecute(cursor,0); // OK
...
status = SQLfetch(cursor,0); // OK
...


sqlo_loadNames(*cursor, result->n_ocols + 1); // This function is mine


result->ocol_names = sqlo_ocol_names(*cursor, &type); // returns an array of null pointers





The sqlo_loadNames function is a function that a have made to allow mi aplication to access the private function _define_ocol_by_pos
that is non available from my aplication.

In order to get the names I have put the following code inside the sqlora.c file.

//
// by ihm
//

//
// Ampliation to enable getNames from Advanced interface
//

int sqlo_loadNames(sqlo_stmt_handle_t sth, int num_cols)
{
register sqlo_stmt_ptr_t stp;
int status = SQLO_SUCCESS;

register unsigned int col_pos; /* The column position (1based) */
// ub4 num_cols; /* number of columns in the select list */
sqlo_col_ptr_t colp;

CHECK_STHANDLE(stp, sth, "sqlo_reopen", SQLO_INVALID_STMT_HANDLE);

/* define all columns */
for (col_pos = 1, colp = stp->ocolsv; col_pos <= (unsigned int) num_cols ;
++col_pos, ++colp)
{
_define_ocol_by_pos(stp, colp, col_pos);
}
return 1;
}

I know that this is a bad solution but is the only one that i have.


2 - My second problem is that i don't know how much space allocate in a string when i call tho the sqlo_define_by_pos function.
Maybe a solution can be to implement a new sqlo_define_by_pos3 function with a double pointer to the data:

sqlo_define_by_pos3 ( stmt , pos, type, void **the_data, int *size, ...

And the sqlo_fetch, command allocates the memory and stores a pointer of the data inside the the_data double pointer when the true size of the data will be know:

*the_data = __malloc(...);
snprintf ( *the_data, the_size, ... ); // or some similar.

The followind problem is who frees the memory: the sqlora library or the user. But i thing this situation is the same that the situation of the
allocation of "alloc_lob" and "free_lob" with the lob's API.

Thanks in advance:

22 Jul 2003 07:37 yatos

A little problem with sqlo_ocol_names... ( part II )

/* define all columns */
for (col_pos = 1, colp = stp->ocolsv; col_pos

22 Jul 2003 07:31 yatos

A little problem with sqlo_ocol_names and memory alloc size

Hello :

My name is Ignacio Holgado. Apologies for my english ( I am spanish ).
I am developping an aplication server with oracle support in a multithreaded environment in a SuSe O.S.
I have developped a "cursor object" in order to allow the access to a generic database from the aplications dispatched by my aplication server.
The first implementation of this cursor object was implemented using the "easy interface" but now I need some functionalities from the advanced interface
and i have 2 litle problems:

1 - My first problem is that i can't obtain the column names from the advanced interface. It seams that it don't works with the "advanced interface". Maybe i am not using it propertly. I have made a bad solution and i would like to have a better solution.
I use it with the following code :



...
*cursor = sqlo_prepare ( *connection, sql_stmt ); // runs OK
...
status = SQLexecute(cursor,0); // runs OK ( this is a wrapper to sqlo_execute )
...
result->n_ocols = sqlo_ncols(*cursor, 0); // returns the number of columns OK !!
...
...
for (type = SQLgetColType(cursor,i+1); (type>=0) && (in_ocols);type = SQLgetColType(cursor,(++i)+1))
{
...
if (SQLO_SUCCESS != (status = sqlo_define_by_pos(*cursor, i+1, type, result->data[2*i], size, result->data[2*i+1],&(result->length[i]),0)))
{
....
....
}
}

...
status = SQLexecute(cursor,0); // OK
...
status = SQLfetch(cursor,0); // OK
...


sqlo_loadNames(*cursor, result->n_ocols + 1); // This function is mine


result->ocol_names = sqlo_ocol_names(*cursor, &type); // returns an array of null pointers





The sqlo_loadNames function is a function that a have made to allow mi aplication to access the private function _define_ocol_by_pos
that is non available from my aplication.

In order to get the names I have put the following code inside the sqlora.c file.

//
// by ihm
//

//
// Ampliation to enable getNames from Advanced interface
//

int sqlo_loadNames(sqlo_stmt_handle_t sth, int num_cols)
{
register sqlo_stmt_ptr_t stp;
int status = SQLO_SUCCESS;

register unsigned int col_pos; /* The column position (1based) */
// ub4 num_cols; /* number of columns in the select list */
sqlo_col_ptr_t colp;

CHECK_STHANDLE(stp, sth, "sqlo_reopen", SQLO_INVALID_STMT_HANDLE);

/* define all columns */
for (col_pos = 1, colp = stp->ocolsv; col_pos

23 Apr 2002 02:06 poitsch

Re: Can it install on Red Hat 7.2 successfully?
Please send problem reports directly to libsqlora8@poitschke.de.

Please include the output of your configure run.

Kai

22 Apr 2002 21:53 beershow

Can it install on Red Hat 7.2 successfully?
The environment is Redhat 7.2, oracle8.1.7,and I copy the package to "/root". And the errors echo as follow:
#make
make all-recursive
make[1]: Entering directory `/root/libsqlora8-2.2.0'
Making all in .
make[2]: Entering directory `/root/libsqlora8-2.2.0'
source='sqlora.c' object='sqlora.lo' libtool=yes \
depfile='.deps/sqlora.Plo' tmpdepfile='.deps/sqlora.TPlo' \
depmode=gcc3 /bin/sh ./depcomp \
/bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I. -I/oracle/product/8.1.7/rdbms/demo -I/oracle/product/8.1.7/rdbms/public -I/oracle/product/8.1.7/precomp/public -DBUILD_DATE="\"Tue Apr 23 09:35:40 CST 2002\"" -O3 -Wall -c -o sqlora.lo `test -f sqlora.c || echo './'`sqlora.c
rm -f .libs/sqlora.lo
gcc -DHAVE_CONFIG_H -I. -I. -I. -I/oracle/product/8.1.7/rdbms/demo -I/oracle/product/8.1.7/rdbms/public -I/oracle/product/8.1.7/precomp/public "-DBUILD_DATE=\"Tue Apr 23 09:35:40 CST 2002\"" -O3 -Wall -c sqlora.c -MT sqlora.lo -MD -MP -MF .deps/sqlora.TPlo -fPIC -DPIC -o .libs/sqlora.lo
sqlora.c:772: conflicting types for `strdup'
/usr/include/string.h:120: previous declaration of `strdup'
make[2]: *** [sqlora.lo] Error 1
make[2]: Leaving directory `/root/libsqlora8-2.2.0'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/libsqlora8-2.2.0'
make: *** [all] Error 2

Your assistance will be high appreciated! : )

Screenshot

Project Spotlight

MeTA1

A message transfer agent.

Screenshot

Project Spotlight

pride

Poor Richard's Independent anDroid Environment.