FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour DBF TEMPORARY
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: DBF TEMPORARY

Posted: Mon Jul 13, 2015 03:28 PM
nageswaragunupudi wrote:HB_DBCreateTemp( cAlias, aStruct, cRDD ) --> lSuccess
... use cAlias like any other alias
CLOSE cAlias at the end

Hi,
I am trying to substitute temporary database file with this, how can I associate an area to it?
Regards,
Antonino
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: DBF TEMPORARY

Posted: Mon Jul 13, 2015 11:58 PM

The first parameter itself is an Alias ( not a file name ) and this Alias is the workarea.

Example:
cAlias := cGetNewAlias()
if HB_DbCreateTemp( cAlias, aStruct, cRDD )
// do work with cAlias
// ? SELECT( cArea ) is the number of the work area.
CLOSE cAlias
endif

Regards



G. N. Rao.

Hyderabad, India
Posts: 76
Joined: Fri Dec 30, 2005 10:25 AM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 11:34 AM

Hb_DbCreateTemp is a really good feature. I did not know this before. Is there also the possibility to create an index file and open?

Frank-Peter
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 11:37 AM

You can do all operations like a normal DBF.
This is exclusive open.
If the PC has more RAM it is lightning fast.

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 01:51 PM

Since there seems to be a lot of interest in temporary DBFs, I am curious how others are using them?

I don't remember using one in a very long time, so maybe I am missing out on something.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 02:18 PM
nageswaragunupudi wrote:The first parameter itself is an Alias ( not a file name ) and this Alias is the workarea.

Example:
cAlias := cGetNewAlias()
if HB_DbCreateTemp( cAlias, aStruct, cRDD )
// do work with cAlias
// ? SELECT( cArea ) is the number of the work area.
CLOSE cAlias
endif


The Temporary File is created on the hard disk? or in memory?
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 02:54 PM
Biel,

The Temporary File is created on the hard disk? or in memory?


In memory.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 03:54 PM
James Bott wrote:Biel,

The Temporary File is created on the hard disk? or in memory?


In memory.

James

Thanks James, what is confusing me is the 3st parameter cRDD.

I never used but like mentioned Carles there are Memory RDD like ArrayRDD and HB_MEMIO, if not misunderstand hb_DbCreateTemp will use one of those RDD.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 04:04 PM
Biel,

I never used but like mentioned Cales there are Memory RDD like ArrayRDD and HB_MEMIO, if not misunderstand hb_DbCreateTemp will use one of those RDD.


Agreed, it is not clear. Also, does this work only with Harbour or also with xHarbour?

It would be helpful if someone would post a small working example. Anyone?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 05:16 PM
Hi, this is a very small example:
Code (fw): Select all Collapse
#include "fivewin.ch"

Function Main()
local cArq:="TST"
local aStruct:={{ "VEND", "C", 14, 0 },;
                { "NOMV", "C", 40, 0 },;
                { "FILX", "C", 02, 0 } }

   use CUSTOMER     //  Just to see how DBCreateTemp selects areas

   HB_DBCreateTemp(cArq, aStruct)
*
   for nY=1 to 99
       dbappend()
       TST->FILX := str(100-nY,2)
       TST->NOMV := replicate(TST->FILX,10)
       TST->VEND := str(nY,4)
   next
   index on FILX+NOMV+VEND to (cArq)
   browse( "Select:"+str(select(),3) )  //  Show "Select: 2"
   CLOSE
return nil

Regards, Euclides
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 08:17 PM

Hi,

It seems that HB_DBCreateTemp() doesn't exist in xharbour..

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 09:31 PM

Euclides,

Thanks much for the example. I have it working. Do you know what RDD the function defaults to?

Marc,

I am running it successfully with xHarbour (ver 1.2.3). I believe this is the latest version and it is from 2013. Is yours older?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 10:41 PM

Defaults to the default RDD of the application.
But I always used "DBFCDX" as the 3rd parameter.
Works with Harbour and xHarbour.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM

Re: DBF TEMPORARY

Posted: Wed Jul 15, 2015 08:00 AM
James Bott wrote:
Marc,

I am running it successfully with xHarbour (ver 1.2.3). I believe this is the latest version and it is from 2013. Is yours older?

James


James,

Indeed, I use an older version of xharbour.

Mobiel verstuurd via Tapatalk
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: DBF TEMPORARY

Posted: Wed Jul 15, 2015 09:12 AM
I am not able to use them, in my program I have all area in numbers.
look this code:
Code (fw): Select all Collapse
proc main()
   local cArq:="test",i
   LOCAL t1 := hb_milliSeconds(), t2
   
   FERASE( cArq+".dbf" ) // 
   dbSelectArea(2)
   dbCreate( cArq, { { "ITEM", "N", 10, 2 },{ "RAND", "N", 10, 2 },{ "TESTO", "C", 10, 0 } } )
   USE (cArq)
   dbSelectArea(1)
   
   t2 := hb_milliSeconds()
   ? "Database creation: " + str(t2-t1) + "msec"
   t1 := t2
   
   for i:=1 to 100000 
      (2)->(dbAppend())
      (2)->ITEM := i / 100
      (2)->RAND = hb_Random(100)
      (2)->TESTO = hb_randStr(10)
   next
   
   t2 := hb_milliSeconds()
   ? "100.000 fields in " + str(t2-t1) + "msec"
   t1 := t2

   dbSelectArea(2)
   INDEX ON STR(FIELD->RAND,6,2)+STR(FIELD->ITEM,6,2) TAG "ITEST"
   
   OrdSetFocus( "ITEST" )
   DBGOTOP()

   t2 := hb_milliSeconds()
   ? "index in " + str(t2-t1) + "msec"
   t1 := t2
   
   WAIT "Press a key..." 
   browse(2)
   close
return

Our program is like this, but spread in about ten source files.

I tried to convert it with HB_DBCreateTemp, but without success, if I try it with "ARRAYRDD" is slower.