Page 2 of 4

Re: DBF TEMPORARY

Posted: Mon Jul 13, 2015 3:28 pm
by AntoninoP
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

Re: DBF TEMPORARY

Posted: Mon Jul 13, 2015 11:58 pm
by nageswaragunupudi
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

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 11:34 am
by fp
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?

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 11:37 am
by nageswaragunupudi
You can do all operations like a normal DBF.
This is exclusive open.
If the PC has more RAM it is lightning fast.

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 1:51 pm
by James Bott
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

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 2:18 pm
by Biel EA6DD
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?

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 2:54 pm
by James Bott
Biel,
The Temporary File is created on the hard disk? or in memory?
In memory.

James

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 3:54 pm
by Biel EA6DD
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.

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 4:04 pm
by James Bott
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

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 5:16 pm
by Euclides
Hi, this is a very small example:

Code: Select all

#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

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 8:17 pm
by Marc Vanzegbroeck
Hi,

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

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 9:31 pm
by James Bott
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

Re: DBF TEMPORARY

Posted: Tue Jul 14, 2015 10:41 pm
by nageswaragunupudi
Defaults to the default RDD of the application.
But I always used "DBFCDX" as the 3rd parameter.
Works with Harbour and xHarbour.

Re: DBF TEMPORARY

Posted: Wed Jul 15, 2015 8:00 am
by Marc Vanzegbroeck
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

Re: DBF TEMPORARY

Posted: Wed Jul 15, 2015 9:12 am
by AntoninoP
I am not able to use them, in my program I have all area in numbers.
look this code:

Code: Select all

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.