ODBC/C++ question
Posted in 2000
Topics: Connectivity: ODBC / JDBC / .NET, Data Types & Schema Design, Platform-Specific Issues, Java & JDBC Development
Hello everyone,
Does anybody here know of a tool that can turn SQL schema into C++ classes
complete with member functions that use the ODBC API to query, insert,
update and delete rows? In other words it sure would be nice to have an
automated way of turning something like this:
create table customer (
id INTEGER NOT NULL,
name varchar(30));
into a Customer class that does all the nasty SQLBindCol, SQLFetch for you
for a query operation and the SQLBindParameter, SQLPrepare for insert
operations and knows to pass the correct arguments like SQL_C_SLONG and
SQL_C_CHAR?
I have no idea if this is remotely possible but it sure would be nice. For
a small application it's not really necessary but when you have 15-20
tables with some of them having 15-20 columns it becomes a nightmare to
code all this stuff in ODBC. I can't imagine bigger tables with 100 or
more columns and having to code 100 calls to SQLBindCol.
I know that with JDBC there is a tool part of Enhydra called DODS that
will do exactly this, you just give it your schema and it spits
out all the necessary Java classes with methods to insert, query and
delete rows. This url explains it if you are
curious: http://www.enhydra.org/software/documentation/enhydra/DODS.html
But with C++ and ODBC is there a way of doing the same thing?
It would have to be a unix program or maybe some perl script since this is
for a Linux platform.
Thanks,
--
Paul Schmidt
pws@best.com
No, but if you get the source to my dbstruct.ec program (in the package
utils_ak in the IIUG Software Repository) you should be able to modify it
to output the basic handling function class members. It currently generates
C structs from the system catalog tables.
Art S. Kagel
Paul Schmidt wrote:
>
> Hello everyone,
>
> Does anybody here know of a tool that can turn SQL schema into C++ classes
> complete with member functions that use the ODBC API to query, insert,
> update and delete rows? In other words it sure would be nice to have an
> automated way of turning something like this:
>
> create table customer (
> id INTEGER NOT NULL,
> name varchar(30));>
> into a Customer class that does all the nasty SQLBindCol, SQLFetch for you
> for a query operation and the SQLBindParameter, SQLPrepare for insert
> operations and knows to pass the correct arguments like SQL_C_SLONG and
> SQL_C_CHAR?
>
> I have no idea if this is remotely possible but it sure would be nice. For
> a small application it's not really necessary but when you have 15-20
> tables with some of them having 15-20 columns it becomes a nightmare to
> code all this stuff in ODBC. I can't imagine bigger tables with 100 or
> more columns and having to code 100 calls to SQLBindCol.
>
> I know that with JDBC there is a tool part of Enhydra called DODS that
> will do exactly this, you just give it your schema and it spits
> out all the necessary Java classes with methods to insert, query and
> delete rows. This url explains it if you are
> curious: http://www.enhydra.org/software/documentation/enhydra/DODS.html
> But with C++ and ODBC is there a way of doing the same thing?
> It would have to be a unix program or maybe some perl script since this is
> for a Linux platform.
>
> Thanks,
>
> --
> Paul Schmidt
> pws@best.com