oCn:ImportFromDBF function autoincrement id feature (Solved)

oCn:ImportFromDBF function autoincrement id feature (Solved)

Postby Horizon » Sun Aug 26, 2018 6: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: 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.
Last edited by Horizon on Mon Aug 27, 2018 12:48 pm, edited 1 time in total.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: oCn:ImportFromDBF function autoincrement id feature problem

Postby nageswaragunupudi » Sun Aug 26, 2018 7: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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: oCn:ImportFromDBF function autoincrement id feature problem

Postby Horizon » Sun Aug 26, 2018 7: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: oCn:ImportFromDBF function autoincrement id feature problem

Postby Horizon » Mon Aug 27, 2018 10:36 am

?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: oCn:ImportFromDBF function autoincrement id feature problem

Postby nageswaragunupudi » Mon Aug 27, 2018 11:04 am

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 )

Regards

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

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

Postby Horizon » Mon Aug 27, 2018 12:46 pm

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.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 114 guests