tdatabase for append / copy

tdatabase for append / copy

Postby TimStone » Fri Sep 16, 2011 4:24 pm

I'm a fan of data objects ( tdatabase / tdata ). Credit James Bott with introducing me to them and it makes my work so much easier.

Two capabilities missing from these classes is:

oDbf:CopyTo( oDbf2 ) which would allow us to copy all, or filtered, contents of an open data object to a new data file

and

oDbf:AppendFrom( oDbf2 ) which would allow us to append all, or filtered, records from a second database

Does anyone have these two functions now ? If not, I will work on them and provide them to Antonio for inclusion in tDatabase.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: tdatabase for append / copy

Postby Antonio Linares » Fri Sep 16, 2011 5:02 pm

Tim,

I have not tested it myself but it seems as this may be a valid starting point:

Code: Select all  Expand view

METHOD CopyTo( oDbf, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) CLASS TDataBase

   local uVal

   if ValType( oDbf ) == "O"
      uVal = ( ::cAlias )->( __dbCopy( oDbf:cAlias, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) )
   endif

return uVal
 

We could copy the records through the target object, but I think that may slow down the process very much
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: tdatabase for append / copy

Postby TimStone » Sun Sep 18, 2011 5:28 pm

Not exactly working ... yet ... will work with it this week. It didn't like the object.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: tdatabase for append / copy

Postby James Bott » Sun Sep 18, 2011 6:42 pm

Try this:

Code: Select all  Expand view
METHOD CopyTo( cFile, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) CLASS TDataBase

   LOCAL uVal
   uVal = ( ::cAlias )->( __dbCopy( cFile, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) )
   
return uVal

Here is a sample test program:

Code: Select all  Expand view
// Test for copyto() method
function main
   local oDB
   oDB:= Tdatabase():new()
   oDB:open(,"clients")
   oDB:copyto( "temp" )
   oDB:close()
   msgInfo( "done")
return nil

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: tdatabase for append / copy

Postby James Bott » Sun Sep 18, 2011 7:34 pm

And here is an AppendFrom() method.

Code: Select all  Expand view
METHOD AppendFrom( cFile, aFields, bFor, bWhile, nNext, nRec, lRest ) CLASS TDataBase

     __dbApp( cFile, aFields, bFor, bWhile, nNext, nRec, lRest )
     
return nil

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: tdatabase for append / copy

Postby Antonio Linares » Sun Sep 18, 2011 7:52 pm

James,

thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: tdatabase for append / copy

Postby TimStone » Sun Sep 18, 2011 11:21 pm

Thanks. Where can I find a reference listing ( document ) for xHarbour __db???????? functions. Its not in the manual.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: tdatabase for append / copy

Postby Gale FORd » Mon Sep 19, 2011 12:12 am

You can find a reference to it in std.ch
Keep in mind this does not cover sdf or delimited.

#command APPEND [FROM <(f)>] [FIELDS <fields,...>] ;
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
[RECORD <rec>] [<rest:REST>] [ALL] [VIA <rdd>] ;
[CODEPAGE <cp>] [CONNECTION <conn>] => ;
__dbApp( <(f)>, { <(fields)> }, ;
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <rdd>, <conn>, <cp> )
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: tdatabase for append / copy

Postby TimStone » Mon Sep 19, 2011 5:18 pm

Thanks Gale. Actually I'm looking for a list of all __dbxxxxx( ) functions.

I'm always appreciative when someone provides a command syntax here, but wonder where they come from because I can't find any of it in my documentation.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: tdatabase for append / copy

Postby nageswaragunupudi » Mon Sep 19, 2011 5:50 pm

Please read and study std.ch file in the (x)harbour\include folder.
These are the default command translates of all xbase commands into clipper/harbour functions.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tdatabase for append / copy

Postby James Bott » Mon Sep 19, 2011 11:09 pm

Here is a list of just the __db functions. There are others starting with leading double underscores. These are all in the STD.CH file.

You can find the syntax for these by Googling them.

__dbPack()
__dbZap()
__dbContinue()
__dbLocate()
__dbCreate()
__dbCopyStuct()
__dbCopyXStruct()
__dbDelim()
__dbSDF()
__dbCopy()
__dbApp()
__dbSort()
__dbTotal()
__dbUpdate()
__dbJoin()
__dbList()
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests