FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour For Each use...
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
For Each use...
Posted: Mon Aug 08, 2016 03:13 PM

Hi everybody

I have a doubt

I have a Mysql Select with Tdolphin which contains a number of rows. Sometimes as many as 15000 rows, I have to transform it to an array to do some operations on the data.

Rigth now I'm doing this.

Local xArr:={}
Local xDb:=tDolphinQry():New("select f1, f2, f3 from xTable", oSvr)
Local x:=0

For x=1 to xDb:nRecCount
xDb:getRow()
Aadd(xArr,{f1,f2,f3,1,.F.})
xDb:Skip()
Next

How do I change it to FOR...EACH, It's been quite fast for working with arrays, but I can't make it work with Tdolphin's select, I'm adding some values to the array, so I can't use xDb:FillArray()

Thanks in advance.

From Chile
Adolfo

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: For Each use...
Posted: Mon Aug 08, 2016 03:41 PM

For instance...
If I do this

For EACH x IN xDb
Aadd(xArr,{F1,F2,F3,1,.F.})
xDb:Skip()
Next

I get only 38 records from the total of 6900, No Error of any type, tha's starnge, only works for a piece of the total data

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: For Each use...
Posted: Mon Aug 08, 2016 05:27 PM

How many fields there are in xDb?

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: For Each use...
Posted: Mon Aug 08, 2016 05:29 PM

Probably you are iterating through a default property of xDb, not through records.

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: For Each use...
Posted: Tue Aug 09, 2016 02:27 AM

Mr Adolfo

Your case is not fit for using FOR EACH ... This can be used only for Arrays.

Note:
This is only for general information. Not for dolphin
FWH RowSet ( oQuery ) has GetRows method.

aRows := oQry:GetRows()

Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: For Each use...
Posted: Tue Aug 09, 2016 02:58 AM

Thanks.. gonna try another aproach.

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650

Continue the discussion