FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oCn:ImportFromDBF function autoincrement id feature (Solved)
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
oCn:ImportFromDBF function autoincrement id feature (Solved)
Posted: Sun Aug 26, 2018 06:55 PM
Hi,

I try to migrate my own tables to MariaDB. I used to DBFCDX.

Most of my tables has a autoincrement field that is maintained for my application. I did not know there was a "+" field type in DBFCDX. So for example my autoincrement field type is "N" and name is "PLK_ID". These field is unique.

Code (fw): Select all Collapse
cMYAU_ID:="PLK_ID"
ocn:importfromdbf(cPath+"\"+ALLTRIM(aDir[i,1] ), cTableName,,,,cMYAU_ID)


I execute these codes and my dbf file imported to mariadb.

There was not added "id" field as an autoincrement field. it is ok.
But My autoincrement field is not set as an AUTOINCREMENT. I can edit in HeidiSQL. But I have lots of tables.

Something I'm doing wrong?

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oCn:ImportFromDBF function autoincrement id feature problem
Posted: Sun Aug 26, 2018 07:44 PM
Most of my tables has a autoincrement field that is maintained for my application. I did not know there was a "+" field type in DBFCDX. So for example my autoincrement field type is "N" and name is "PLK_ID". These field is unique.

If the field type in DBF is "N", it is not an autoincrement field. It is a numeric field and you are ensuring its uniqueness through your program logic. Am I right?

In that case, please let us know how do you like to maintain this field in MySql?
(a) As Autoincrement field? In that case, the server itself increments the value and you can not programmatically assign any values to this field.
OR
(b) As a simple numeric field? In that case you should programmatically keep on assigning unique values as when a record is inserted.

Option (a) is desirable.

If you let us know if you want option (a) or (b), we will advise you the suitable way.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: oCn:ImportFromDBF function autoincrement id feature problem
Posted: Sun Aug 26, 2018 07:58 PM
Hi Mr. Rao,

If the field type in DBF is "N", it is not an autoincrement field. It is a numeric field and you are ensuring its uniqueness through your program logic. Am I right?

Right.

If you let us know if you want option (a) or (b), we will advise you the suitable way.

of course (a). but just for migration of data, my "PLK_ID" 's values should not been changed.

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: oCn:ImportFromDBF function autoincrement id feature problem
Posted: Mon Aug 27, 2018 10:36 AM

?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oCn:ImportFromDBF function autoincrement id feature problem
Posted: Mon Aug 27, 2018 11:04 AM
Code (fw): Select all Collapse
cDBF     := cPath + "\" + aDir[ i, 1 ]
aStruct  := FW_DBFSTRUCT( cDbf )
AEVAL( aStruct, { |a| If( a[ 1 ] == "PLK_ID", a[ 2 ] := "+", nil ) } )
oCn:ImportFromDBF( Lower( cDbf ), nil, nil, nil, aStruct )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: oCn:ImportFromDBF function autoincrement id feature (Solved)
Posted: Mon Aug 27, 2018 12:46 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
cDBF     := cPath + "\" + aDir[ i, 1 ]
aStruct  := FW_DBFSTRUCT( cDbf )
AEVAL( aStruct, { |a| If( a[ 1 ] == "PLK_ID", a[ 2 ] := "+", nil ) } )
oCn:ImportFromDBF( Lower( cDbf ), nil, nil, nil, aStruct )


Thank you Mr. Rao. It solved my problem.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion