Does "+" fields are replaceable ?

Issues and Discussions related to Harbour

Moderator: Rathinagiri

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

Does "+" fields are replaceable ?

Post by esgici »

FYI :

Code: Select all

PROC Main()

  DBCREATE( "AInsTest", { { "FLD1", "+", 4, 0 } },,.T. )
  
  FOR nRec := 1 TO 3
      DBAPPEND()
  NEXT

  GO 2
  
  REPL FLD1 WITH 10

RETU
  
Regards
Viva INTERNATIONAL HMG :D
martingz
Posts: 394
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico

Re: Does "+" fields are replaceable ?

Post by martingz »

Esgici , I tested some time ago and gave me data type error
DBFCDX/1020
cant' be replaceable

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

Re: Does "+" fields are replaceable ?

Post by esgici »

Yes Martin

In Harbour exactly this is.

Thanks

Regards
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Does "+" fields are replaceable ?

Post by Pablo César »

Hi amigo Esgici,

This field "+" Autoincrement type, I never used before and I do not fully know how to use it (I means, if you delete a record should restores a value deleted for next use). This field type, seems is for FoxPro RDD not Clipper/Dbase. See tests I made:

Code: Select all

#include <hmg.ch>

Function Main
Local cRDD:="Clipper"
// "Harbour/FPT"

// DBCREATE( "AInsTest", { { "FLD1"+"+", 4, 0 } },"",.T. )
cToRDD:=If(cRDD="Harbour/FPT",'DBFCDX','DBFNTX')
If !File("AInsTest.Dbf")
   DbCreate("AInsTest",{ { "FLD1", "+", 4, 0 } },cToRDD)
Endif

Use AInsTest
FOR nRec := 1 TO 3
    DBAPPEND()
NEXT

GO Bottom

// REPLACE FLD1 WITH +10

MsgInfo(Str(FLD1))
Return
It´s seems you can not make data replacement in this type of field. This is automatic increment value.
I make some implements in you code/example just to put in evidence that this field works automatically.

Probably value of autoincrement Step, can be changed in the 23rd Byte offset in Header Structure of dbf.

Read this:
http://www.dbf2002.com/dbf-file-format.html
and this:
http://www.jpmartel.com/bu02auto.htm

I also noted when I try to edit this dbf with autoincrement field, it is displaying an Error DBFNTX/1020 Data type error thru DBA.exe (for example). And in DBFView of Grigory Filatov, also can not edit but displaying a message "Edit of this field is not supported." but when try to see table´s properties, it´s interrupt with an error of array´s lenght.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Does "+" fields are replaceable ?

Post by mol »

Some weeks ago,Przemek Czerpak wrote about autoincrement fields on the harbour mailing list:
El 18/06/2012 15:31, Przemysław Czerpak escribió:
> Hi Juan,
>
> We do not have and fieldinfo actions which can be used to control
> autoincrement values (counter and step).
> I'll try to remember about it and them in the future.
>
> best regards,
> Przemek
>
>
> On Mon, 18 Jun 2012, Juan Gálvez wrote:
>> Any comments ?
>>
>> El 23/05/2012 16:49, Juan Gálvez escribió:
>>> Hi all, Przemek,
>>>
>>> Is there any DbFieldInfo() to set/get the counter and step values of
>>> autoinc fields (+) ?
>>>
>>> Many thanks
>>> Juan
So, Ithink, once created autoinc field cannot be set by user.
Marek
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Does "+" fields are replaceable ?

Post by esgici »

Hi

Martin, Marek and Pablo probably understood that I had asked this question for learn the answer. By putting a special word FYI ( For Your Information ) at beginning of post I want say :
"NO ! as you see below sample, auto increment fields doesn't replaceable in Harbour".
Sorry for my weak English :(

Ola Pablo

Thanks to additional info :)

But; does my sample not evident to show how auto increment type fields work ?

Please look at see here for a sample for all extended field types added to Clipper implementation by Harbour.

And, as you know, since default RDD in Harbour is DBFNTX,

Code: Select all

DBCREATE( "AInsTest", { { "FLD1"+"+", 4, 0 } },"",.T. )
is equal to

Code: Select all

DBCREATE( "AInsTest", { { "FLD1"+"+", 4, 0 } },"DBFNTX",.T. )
Apparently you had tested under both ( DBFNTX,DBFCDX ) RDD and seen that auto increment field is implemented both ( most probably all ) RDD.

In this case which result we will expect by changing 3rd byte of table structure, please let me know.

DBA doesn't support (for now) extended field types, because this concept is newer than DBA.

Please also look at here (if you are wondering) :

Moderator of Clipper Online forum says frequently :
"Please search through forum posts before writing on any subject."
Sorry for this long ( and mostly unnecessary ) speech. I like "chatting" with you ;)

Cumprimentos :D
Last edited by esgici on Thu Oct 04, 2012 3:26 pm, edited 1 time in total.
Viva INTERNATIONAL HMG :D
martingz
Posts: 394
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico

Re: Does "+" fields are replaceable ?

Post by martingz »

For info only

ourXdbu - version 1.7.0.2
by: Miguel Angel Marchuet Frutos

support autoinc fields

Regrads
User avatar
Hazael
Posts: 109
Joined: Thu Jun 24, 2010 11:37 am
Location: France

Re: Does "+" fields are replaceable ?

Post by Hazael »

AFAIK you can change the counter with

DbFieldInfo( DBS_COUNTER, 1, 10 )
DbAppend()
Harbour | GTWVT | MingW | Visual Studio Code
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Does "+" fields are replaceable ?

Post by Pablo César »

#include "DBINFO.CH"

Use AInsTest
DbFieldInfo( DBS_COUNTER, 1, 10) // Reset count from number 10
DbFieldInfo( DBS_STEP, 1, 5) // Change counter from 5 to 5
FOR nRec := 1 TO 3
DBAPPEND()
NEXT
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Does "+" fields are replaceable ?

Post by esgici »

Qatan wrote:AFAIK you can change the counter with
DbFieldInfo( DBS_COUNTER, 1, 10 )
DbAppend()
Pablo César wrote:#include "DBINFO.CH"
Use AInsTest
DbFieldInfo( DBS_COUNTER, 1, 10) // Reset count from number 10
DbFieldInfo( DBS_STEP, 1, 5) // Change counter from 5 to 5
FOR nRec := 1 TO 3
DBAPPEND()
NEXT
For prevent anyone to misunderstand :

In Harbour, changing and /or resetting counter of auto-increment process, doesn't change un-replaceable property of those fields.

FYI only.

Regards
Viva INTERNATIONAL HMG :D
Post Reply