Help - somebody? anybody?

From: Grinnell Almy <galmy_at_webvision.com>
Date: 1997/11/04
Message-ID: <345F97E3.EE448ED6_at_webvision.com>


--------------C3EA852F9FF4394A4CEE117F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I have a problem, and I hope someone has a solution, or at least a suggestion.

I am using Oracle Objects to access Oracle databases from an MSVC++ application.
The program contains the following code. The variable "Database" is an ODatabase; at this point in the code we have already logged in to ExampleDB. The variable "msg" is a string containing the SQL query; in this example, I'm using "select * from emp".

// Try to execute the query.

    Dynaset = ODynaset(Database, msg);

// If we were successfull...

    if (Dynaset.IsOpen())
    {

        // Create a value holder.
        Field = OField();
        // How many columns are there?
        ncols = Dynaset.GetFieldCount();
        // For each row...
        do
        {
            // ...and for each column...
            for (i = 0; i < ncols; i++)
            {
                // ...get the data and add it to the return
string.
                Field = Dynaset.GetField(i);
                if (Field.IsOpen())
                {
                    if (!rmsg.IsEmpty()) rmsg += LF;
                    // These four lines were added for debugging
                    int n = (int)Field;
                    long l = (long)Field;
                    double d = (double)Field;
                    const char* x = (const char *)Field;
                    rmsg += (const char *)Field;
                }
                else
                    /* error processing goes here */
               // endif
            }
            // next i
            ores = Dynaset.MoveNext();
        }
        while (!Dynaset.IsLast() && !Dynaset.IsEOF());
    }
    else

        rmsg = SQLErrorHandler(DYNASET);
// endif

    Field.~OField();
    Dynaset.~ODynaset();

The code works, up to a point. The do loop is travelled the correct number of times, corresponding to the number of rows in emp; the call to GetFieldCount() returns 8, which is the correct number of columns in emp. After each call to GetField(), the call to Field.IsOpen() returns true, so we should be getting data. But every time, the int, long and double casts return zero, and the char* cast returns an empty string. Where's the data?

Anybody have any ideas?

--
Grinnell Almy
galmy_at_webvision.com
--
"You can't talk to a man with a shotgun in his hand"
   Carole King

--------------C3EA852F9FF4394A4CEE117F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>I have a problem, and I hope someone has a solution, or at least a
suggestion.</TT><TT></TT>

<P><TT>I am using Oracle Objects to access Oracle databases from an MSVC++
application.</TT>
<BR><TT>The program contains the following code. The variable "Database"
is an ODatabase; at this point in the code we have already logged in to
ExampleDB. The variable "msg" is a string containing the SQL query; in
this example, I'm using "select * from emp".</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; // Try to execute the query.</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Dynaset = ODynaset(Database, msg);</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; // If we were successfull...</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; if (Dynaset.IsOpen())</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create a value holder.</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Field = OField();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // How many columns
are there?</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ncols = Dynaset.GetFieldCount();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // For each row...</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// ...and for each column...</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for (i = 0; i &lt; ncols; i++)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// ...get the data and add it to the return string.</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Field = Dynaset.GetField(i);</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (Field.IsOpen())</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (!rmsg.IsEmpty()) rmsg += LF;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// These four lines were added for debugging</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int n = (int)Field;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
long l = (long)Field;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
double d = (double)Field;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char* x = (const char *)Field;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
rmsg += (const char *)Field;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* error processing goes here */</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// endif</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// next i</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ores = Dynaset.MoveNext();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!Dynaset.IsLast()
&amp;&amp; !Dynaset.IsEOF());</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; else</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rmsg = SQLErrorHandler(DYNASET);</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; // endif</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Field.~OField();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Dynaset.~ODynaset();</TT><TT></TT>

<P><TT>The code works, up to a point. The do loop is travelled the correct
number of times, corresponding to the number of rows in emp; the call to
GetFieldCount() returns 8, which is the correct number of columns in emp.
After each call to GetField(), the call to Field.IsOpen() returns true,
so we should be getting data. But every time, the int, long and double
casts return zero, and the char* cast returns an empty string. Where's
the data?</TT><TT></TT>

<P><TT>Anybody have any ideas?</TT>
<BR><TT>--</TT>
<BR><TT>Grinnell Almy</TT>
<BR><TT>galmy_at_webvision.com</TT>
<BR><TT>--</TT>
<BR><TT>"You can't talk to a man with a shotgun in his hand"</TT>
<BR><TT>&nbsp;&nbsp; Carole King</TT></HTML>

--------------C3EA852F9FF4394A4CEE117F--
Received on Tue Nov 04 1997 - 00:00:00 CET

Original text of this message