rghome
05-05-2003, 10:15 AM
I am trying to design an API using stored procedures to encapsulate our database. The idea is that the C development department doesn't know about the internal database structure (tables, etc) but instead accesses it though stored procedures. This allows the DBA change the tables, and as long as the stored procedure signatures stay the same, the developers won't be affected.
To do this, I need to be able to call a stored procedure from C and have it return a number of rows of data.
For example, from C I need to be able to do something like:
EXEC SQL BEGIN DECLARE ...
struct Customer {
char name[50];
char company[50];
int accountNumber;
};
struct Customer customerList[100];
EXEC SQL END DECLARE ...
EXEC SQL CALL getCustomers(:customerList);
So, the stored procedure populates the customerList array with customers from the database. (Or something like that).
I don't think, Oracle doesn't support this syntax. Reading though the Pro*C documentation, there seem to be big restrictions on what you can do, and in parts it seems contradictory (for example, I am not sure if you can use arrays of structures). In any case, there is an obvious problem with the design in that it can only return 100 customers.
Has anybody had experience of doing this kind of thing ? Any suggestions on a possible approach would be apprecidated. In particular, whether you can load data into an array of structures.
We are using Oracle 8.1.4.
Thanks.
To do this, I need to be able to call a stored procedure from C and have it return a number of rows of data.
For example, from C I need to be able to do something like:
EXEC SQL BEGIN DECLARE ...
struct Customer {
char name[50];
char company[50];
int accountNumber;
};
struct Customer customerList[100];
EXEC SQL END DECLARE ...
EXEC SQL CALL getCustomers(:customerList);
So, the stored procedure populates the customerList array with customers from the database. (Or something like that).
I don't think, Oracle doesn't support this syntax. Reading though the Pro*C documentation, there seem to be big restrictions on what you can do, and in parts it seems contradictory (for example, I am not sure if you can use arrays of structures). In any case, there is an obvious problem with the design in that it can only return 100 customers.
Has anybody had experience of doing this kind of thing ? Any suggestions on a possible approach would be apprecidated. In particular, whether you can load data into an array of structures.
We are using Oracle 8.1.4.
Thanks.