Help - somebody? anybody?
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> // Try to execute the query.</TT> <BR><TT> Dynaset = ODynaset(Database, msg);</TT><TT></TT> <P><TT> // If we were successfull...</TT> <BR><TT> if (Dynaset.IsOpen())</TT> <BR><TT> {</TT> <BR><TT> // Create a value holder.</TT> <BR><TT> Field = OField();</TT> <BR><TT> // How many columns are there?</TT> <BR><TT> ncols = Dynaset.GetFieldCount();</TT> <BR><TT> // For each row...</TT> <BR><TT> do</TT> <BR><TT> {</TT> <BR><TT> // ...and for each column...</TT> <BR><TT> for (i = 0; i < ncols; i++)</TT> <BR><TT> {</TT> <BR><TT> // ...get the data and add it to the return string.</TT> <BR><TT> Field = Dynaset.GetField(i);</TT> <BR><TT> if (Field.IsOpen())</TT> <BR><TT> {</TT> <BR><TT> if (!rmsg.IsEmpty()) rmsg += LF;</TT> <BR><TT> // These four lines were added for debugging</TT> <BR><TT> int n = (int)Field;</TT> <BR><TT> long l = (long)Field;</TT> <BR><TT> double d = (double)Field;</TT> <BR><TT> const char* x = (const char *)Field;</TT> <BR><TT> rmsg += (const char *)Field;</TT> <BR><TT> }</TT> <BR><TT> else</TT> <BR><TT> /* error processing goes here */</TT> <BR><TT> // endif</TT> <BR><TT> }</TT> <BR><TT> // next i</TT> <BR><TT> ores = Dynaset.MoveNext();</TT> <BR><TT> }</TT> <BR><TT> while (!Dynaset.IsLast() && !Dynaset.IsEOF());</TT> <BR><TT> }</TT> <BR><TT> else</TT> <BR><TT> rmsg = SQLErrorHandler(DYNASET);</TT> <BR><TT> // endif</TT> <BR><TT> Field.~OField();</TT> <BR><TT> 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> Carole King</TT></HTML> --------------C3EA852F9FF4394A4CEE117F--Received on Tue Nov 04 1997 - 00:00:00 CET