Re: How do you design ProC to work with C++?

From: Michael Krolewski <vandra_at_u.washington.edu>
Date: 1998/07/10
Message-ID: <35A7084F.7157AC9E_at_u.washington.edu>#1/1


gunawan.agus_at_infores.com wrote:

> Hi All,
>
> I used to do my ProC (v2.2.3/Oracle 7.3) programming with C on an HP-UX
> machine and I would like to catch up with the rest of the world and start
> using C++. I have managed to get a simple database object (create the
> connection and closing it) to work by following the instructions on the
> manual. However, I haven't been able to figure out anything much after that.
> For example:
>
> - EXEC SQL CONNECT :userpass AT MY_DB USING :db_string; The "MY_DB" part
> doesn't compile when substituted by a host variable. This is going to
> severely hamper the reusability of the database object.
>
> - Doing a query. With the simple database object, the client can execute
> query just like before (EXEC SQL SELECT...) but this is a screwy thing to do
> and it totally defeats the purpose of OO design. I was trying to build a
> wrapper that let the client submit a query, get back an id, and use the id to
> fetch the next row. I'm also thinking of doing it ala OODBC's Database &
> Dynaset object. To do this, I need a generic fetch that can work for any
> number of columns but I am not sure how to write such thing.
>
> Does anyone tried to do this and is this a feasible thing to try? or would I
> better off trying to pull this with Oracle 8?
>

I think you are trying to hard to fit it into C++. Think of a query/select as afile access. There are open , read (fetch) and close commands. This is directed at selecting a particular object . The reads and by inference the open and close are unique for each object. If you were reading data from a file, you would have to rewrite it for each file.

There is a possible way using ProC or OCI or OTL to create a generic select which can take a very generic select eg 'select * from someTable' and return all the fields. See the column binding functions. This type of functionality is great for extracting lots of data from the database like
when dumping the database tables to ASCII. The disadvantage is because it is generic it is almost impossible to assign the data to any sort of C class. Which integer
belong to which member item?

If you want to develop you own generic SQL engine, I think you are wasting your time. There are some many engines already and they work.

Mike Krolewski.

> Thanks,
> wan
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Received on Fri Jul 10 1998 - 00:00:00 CEST

Original text of this message