For Each use...

For Each use...

Postby Adolfo » Mon Aug 08, 2016 3: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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: For Each use...

Postby Adolfo » Mon Aug 08, 2016 3: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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: For Each use...

Postby Enrico Maria Giordano » Mon Aug 08, 2016 5:27 pm

How many fields there are in xDb?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: For Each use...

Postby Enrico Maria Giordano » Mon Aug 08, 2016 5:29 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: For Each use...

Postby nageswaragunupudi » Tue Aug 09, 2016 2: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: For Each use...

Postby Adolfo » Tue Aug 09, 2016 2: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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 66 guests