problem with autoincremental field

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

problem with autoincremental field

Post by mol »

Hi!
I'm trying to use autoincremental field.
I want to append some records from one dbf to another. Both files have the same definition. One of fileds is IdRec type: + len.4

phrase:
use f2
append from f1
causes error: Type mismatch: IdRec
Do I need to create my own function to append record by record?

Regards, Marek
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: problem with autoincremental field

Post by esgici »

mol wrote: I'm trying to use autoincremental field.
Hi Mol

Did you examined this :?:

There are too many examples, including "AutoIncrement" fields.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: problem with autoincremental field

Post by mol »

Thx for reply!
But, you didn't understand me, I think.
I want to use simple comand

Code: Select all

Append from.... 
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: problem with autoincremental field

Post by esgici »

mol wrote:Thx for reply!
But, you didn't understand me, I think.
I want to use simple comand

Code: Select all

Append from.... 
You are rigth, I didn't understand you :(

If you are using "AutoIncrement" type ("+") field in your .dbf, you don't need concern APPEND FROM nor REPLACE or anything else;
since "Auto" implies "automatic", everything made by system (RDD you are using) automatically.

But you need a few attention: values of that type fields may diverse between current and appended from files; because value of that fields automatically computes and replaces by system while record append and always protect against replacing manually.

( As far as I know )

Hope useful :?

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: problem with autoincremental field

Post by mol »

I want to append other fields, Esgici.
There is possibility to determine list of fields to append, I'll try to paste this list by macro
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: problem with autoincremental field

Post by esgici »

mol wrote: There is possibility to determine list of fields to append ?
Yes, you have use FIELDS clause, FE:

Code: Select all

APPEND FROM BranchFile FIELDS Branch, Salesman, Amount
You can look at here for details.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: problem with autoincremental field

Post by mol »

Hi!
I want to use such a construction:

Code: Select all

cListOfFields := "Year,Data,Comment"
use f1
append from f2 Fields &cListOfFields
but nothing is appended
Is it another way to paste list of fields?
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: problem with autoincremental field

Post by esgici »

mol wrote: Is it another way to paste list of fields?
Hi Marek

I know, you will not like this too :(

Code: Select all

#include <hmg.ch>

Function Main

   DBCREATE( "TestTo", { {"First", "C", 30, 0 }, {"Last", "C", 30, 0 } } )
   USE TESTTO ALIAS DBF1
   MyAppeFrom( "TestFrom", { "First", "Last" } )
   MsgDebug( LASTREC() )

Return

PROC MyAppeFrom( cAFromFName, aFields )
   
   cFldNam := ""

   USE (cAFromFName) NEW ALIAS DBF2 

   WHILE !EOF()
       SELECT DBF1
       APPEND BLANK
       FOR EACH cFldNam IN aFields
           REPLACE DBF1->&cFldNam WITH DBF2->&cFldNam 
       NEXT cFldNam  
       SELECT DBF2
       SKIP
   ENDDO

   SELECT DBF2
   USE
   SELECT DBF1
   GO TOP


RETU  
Anyway, happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: problem with autoincremental field

Post by mol »

Hi! I know all possibilities to append record by record, but I've searched solution ror APPEND command.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: problem with autoincremental field

Post by esgici »

mol wrote:Hi! I know all possibilities to append record by record, but I've searched solution ror APPEND command.
I wish easiness to you :arrow:

Please inform us too when found :?

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
Post Reply