views:

161

answers:

1

Hi guys,

I'm now working on vbscript to do some test. Actuelly, I want to retrieve a large amount of data from an oracle database, so I write the code like this:

sql = "Select * from CORE_DB where MC = '" & mstr & "' "
Set myrs = db_execute_query(curConnection, sql)

Then I count the rows in myrs,there are 248 rows. So then I do a For loop to retrieve some fields of each row.

For k = 0 To db_get_rows_count(myrs)

But then I found that the content of the row k when k > 133 was always equal to k = 133. So this makes an error.

The db_execute_query function is like

Function db_execute_query ( byRef curSession , SQL)
 set rs = curSession.Execute( SQL )
 set db_execute_query = rs
End Function

The db_get_rows_count function is like

Function db_get_rows_count( byRef curRS )
  dim rows
  rows = 0
  db_get_rows_count = rows
  curRS.MoveFirst
  Do Until curRS.EOF
    rows = rows+1
    curRS.MoveNext
  Loop
  db_get_rows_count = rows
End Function

As I think, there may be a limit size of mrys ? Could anyone light me about this? Thanks a lot in advance

+1  A: 

It would be useful to know what's actually in the database. Can you connect to your database using some other tool (SQLPlus, PL/SQL Developer, Toad, etc) and execute your query? And if you do so, do the results match those that you get when you execute your query through VBScript?

Also, do you get an error from the database? That might help determine what's going on.

Bob Jarvis
@Bob, thanks for your answer, I have verified in the database the expected result, but I haven't execute a sql query in another tool yet. Anyway, I haven't got any error.
Hello, I have tested using SQL Developer, the result is correct, so I think It's maybe the problem of my statements of VBScript
Looking at your code, I'm wondering why you're iterating through the result set to find out how many rows were returned by the query, and then you're going back to process the rows. I suggest that you shouldn't bother counting the rows, just process them as you get them. If you really need to count them before you process the data, you need to be sure there's a curRS.MoveFirst done sometime after you call db_get_rows_count and before you start looking at rows in the result set again.
Bob Jarvis
@Bob, yes, I do realize that it is no so efficient, anyway, I checked the existence of curRs.MoveFirst. But still I want to know that if there is a size limit of "rs". If so, how can I define several "rs" to store the search results?