views:

1054

answers:

2

I've got this code:

rs1 = getResults(sSQL1)
rs2 = getResults(sSQL2)

rs1 and rs2 and 2D arrays. The first index represents the number of columns (static) and the second index represents the number of rows (dynamic).

I need to join the two arrays and store them in rs3. I don't know what type rs1 and rs2 are though.

+1  A: 

Are you sure that the columns will match up? Because if that's not the case I don't know how you'd do it in a generic way in any language. If it is the case, then you could probably do it very simply like this:

rs1 = getResults(sSQL1 & " UNION " sSQL2)
Joel Coehoorn
Yes, I'm sure. They're both executing the same stored procedures (I know, but I didn't write this, I just have to maintain it)
ilitirit
+1  A: 

I've figured it out. Turns out I was doing it the right way all along, I was just off by one. You don't need a third array either.

        aRS_RU = rowsQuery(sSQL & ", 'RU'")
        aRS_KR = rowsQuery(sSQL & ", 'KR'")

        uboundRU1 = UBound(aRS_RU, 1)
        uboundRU2 = UBound(aRS_RU, 2)
        uboundKR2 = Ubound(aRS_KR, 2)

        ' Redim original array
        ReDim Preserve aRS_RU(uboundRU1, uboundRU2 + uboundKR2 + 1 )
        uboundRU2 = UBound(aRS_RU, 2)

        ' Add the values from the second array            
        For m = LBound(aRS_KR, 1) To UBound(aRS_KR, 1)      'Loop for 1st dimension
            For n = LBound(aRS_KR, 2) To UBound(aRS_KR, 2)  'Loop for 2nd dimension
                aRS_RU(m, uboundRU2 + n) = aRS_KR(m,n)
            Next
        Next
ilitirit