Page 1 of 1

oCn:ImportFromDBF function autoincrement id feature (Solved)

PostPosted: Sun Aug 26, 2018 6:55 pm
by Horizon
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: Select all  Expand view
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.

Re: oCn:ImportFromDBF function autoincrement id feature problem

PostPosted: Sun Aug 26, 2018 7:44 pm
by nageswaragunupudi
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.

Re: oCn:ImportFromDBF function autoincrement id feature problem

PostPosted: Sun Aug 26, 2018 7:58 pm
by Horizon
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.

Re: oCn:ImportFromDBF function autoincrement id feature problem

PostPosted: Mon Aug 27, 2018 10:36 am
by Horizon
?

Re: oCn:ImportFromDBF function autoincrement id feature problem

PostPosted: Mon Aug 27, 2018 11:04 am
by nageswaragunupudi
Code: Select all  Expand view
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 )


Re: oCn:ImportFromDBF function autoincrement id feature (Solved)

PostPosted: Mon Aug 27, 2018 12:46 pm
by Horizon
nageswaragunupudi wrote:
Code: Select all  Expand view
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.