Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15925

Generating one recordset from another (output of stored proc)

$
0
0
Hello all,
I have a "SELECT" stored procedure which returns a recordset consisting of about 20 fields. After calling the sp, I use the recordset to populate listview. All of this works fine.
The pertinent code is basically:

Code:

Dim strSQL As String
strSQL = "sp_MyStoredProc ... "
Set rtemp = OpenRecordset(strSQL, adOpenStatic, adLockReadOnly)
While Not rtemp.EOF
    ' populate listview item
    rtemp.MoveNext
Wend

What I'd like to do now is create a "summary" version of my process, which would conceptually consist of using the "rTemp" recordset as if it was a table, where I could either use it in the VB6 program, or create another sp that calls the original sp and processes the origninal sp's resultset.
Conceptually:
"SELECT col1, col2, sum(col3) as the_total FROM rtemp GROUP BY col1, col2"

What are my options for this, if either scenario is possible?

(I know I could write an alternative "summary" version of the original sp, however, all the "hard work" in generating the detailed result recordset is done in the original sp, and I would prefer not to have to duplicate my efforts as well as maintain the code in two places should the general requirements of the detail query change.)

Viewing all articles
Browse latest Browse all 15925

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>