LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Toolkit DBFetchNext

Solved!
Go to solution

Hello all,

I am trying to develope a program that uses SQL Toolkit on CVI 2010. I access to an Oracle database, using an ODBC connection.

I have a problem obtaining the data after a select query .
I am using DBNumberOfRecords to see how many records returns the query.
For getting data I use  DBBindColChar  function, and after DBFetchNext in while loop.
The problem is that value returned by  DBNumberOfRecords is different of values
returned in while loop with DBFetchNext. The correct value is the one returned by  DBNumberOfRecords  function.
I have attached a part of my source coude, where the problem occured.


Thanks in advandce for help!

0 Kudos
Message 1 of 5
(4,304 Views)

Anam,

 

What is the DBFetchNext in the while loop returning outputting? 

 

Is it printing more or fewer times than the number of records returned by DBNumberOfRecords?

 

Regards,

 

Kyle Mozdzyn

Applications Engineering

National Instruments

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 5
(4,267 Views)

Hi,

 

Number of records printed in while loop is lower than the one returned by DBNumberOfRecords.

 

In the loop, DBFetchNext returns 0, but at one point the value returned is -5, meaning that are no more records to print,

which is false.

 

Thanks a lot for your help!

 

 

0 Kudos
Message 3 of 5
(4,259 Views)
Solution
Accepted by Anam

Assuming that DBNumberOfRecords is truly returning the number of records in the select statement, could you answer a few questions for me:

 

1) Does the very first DBFetchNext print the first record you'd expect (assuming you know what the value of the first returned record should be)?

 

2) If you remove the call to DBNumberOfRecords does DBFetchNext print all of the records?

 

3) In your original code, try adding this line directly before your call to DBActivateSQL and let me know if you still have problems:

resCode = DBAllowFetchAnyDirection (dbHandle,TRUE);

 

 

Kevin B.
0 Kudos
Message 4 of 5
(4,170 Views)

Hello Kevin,

 

I found the response to my problem, while I was trying to respond to your questions:

 

1. DBFetchNext prints the first record.

2. If I removed DBNumberOfRecords, the number printed by DBFetchNext was correct!

3. I didn't try this solution, because I found the answer.

 

So thanks a lot for your time and suggestions, it was a great help!

 

0 Kudos
Message 5 of 5
(4,161 Views)