Confused about Multi-dimensional arrays
Posted: Sat Jul 09, 2011 3:50 pm
Hello,
I am trying to create a procedure that will fill an array with data rows from a SQL query. I am having trouble passing the array. I want to dimension it and then redim to the size of the number of rows. Something like this:
What I would like is to be able to dim an array to match the number of colums in my query and have this procedure do the query an fill the array. Is there a better way I could understand? PB has complained about everything I do to pass an array to a procedure. I don't think the help examples are too good at this point.
Help?
Thanks... DB
I am trying to create a procedure that will fill an array with data rows from a SQL query. I am having trouble passing the array. I want to dimension it and then redim to the size of the number of rows. Something like this:
Code: Select all
Procedure.l zExecuteSQLQuery(SQL.s,Array dat(10))
Protected.l hndDB = zOpenSQLDatabase("","")
Protected.l ttlcol,col,count = -1
If IsDatabase(hndDB)
If DatabaseQuery(hndDB,SQL) : Debug SQL
ttlcol = DatabaseColumns(hndDB)
While NextDatabaseRow(hndDB)
count + 1
For col = 0 To ttlcol - 1
dat(count,col) = GetDatabaseString(hndDB,col)
Next col
ReDim dat(count,ttlcol)
Wend
CloseDatabase(hndDB)
EndIf
EndIf
ProcedureReturn count
EndProcedure
Help?
Thanks... DB