FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour CAMPO AUTOINCREMENT - DBF [RESUELTO]
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
CAMPO AUTOINCREMENT - DBF [RESUELTO]
Posted: Sat Oct 18, 2025 05:15 PM

Buen dรญa

Requiero que los campos autoincrement para tablas DBF, inicien en 1 y no en 0...

Jonsson Russi

Colombia

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Sun Oct 19, 2025 06:28 AM

I just tried: autoincrement fields already start from 1.

Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Sun Oct 19, 2025 01:05 PM

Buen dia...

Tengo versiones de feb 2025 de harbour y xharbour.org + bcc77, xharbour.com + fivewin 24.10

y con todas inicia en cero (0)

Gracias

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Sun Oct 19, 2025 01:13 PM

Can you send me a DBF to understand the problem, please?

Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Sun Oct 19, 2025 03:06 PM
enviado via email
โ”‚ CCODIGOART C 16 0 โ”‚
โ”‚ CNOMBREART C 40 0 โ”‚
โ”‚ CUNIMEDART C 12 0 โ”‚
โ”‚ NCANMEDART N 12 2 โ”‚
โ”‚ DULTMODART D 8 0 โ”‚
โ”‚ CNROVERART C 4 0 โ”‚
โ”‚ CNRONOTART C 10 0 โ”‚
โ”‚ COBSPROART C 60 0 โ”‚
โ”‚ CORIPROART C 1 0 โ”‚
โ”‚ ID + 4 0 โ”‚
โ”‚ โ”‚
โ”‚
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Sun Oct 19, 2025 03:17 PM
Thank you. Please try this sample with Harbour and xHarbour. With Harbour the code starts from 1, with xHarbour it starts from 0. What is the correct start value?
#include "Fivewin.ch"


FUNCTION MAIN()

    USE PRUEBA EXCLUSIVE

    ZAP

    APPEND BLANK
    APPEND BLANK

    CLOSE

    XBROWSER( "PRUEBA.DBF" )

    RETURN NIL
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Sun Oct 19, 2025 07:06 PM

Buena tarde...

Estaba haciendo el zap desde un manejador de tablas ---

si la tabla es 100% nueva y/o hago el zap en el mismo app...esta correcto

ya inician en 1...

ya funciono bien con harbour, xharbou.org / .com

Gracias...

Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Tue Oct 21, 2025 11:42 PM
Enrico... buena noche---

Favor verificar el autoincrement cuando la tabla esta poblada y se requiere modificar y agregar el campo autoincrement (+)
Con el codigo anexo inicia en cero(0)
DBUSEAREA(.T.,"DBFCDX","prueba.dbf","XXX",.F.)
select xxx

zap
pack

append from "prueba_.dbf"

XXX->( DBCOMMIT() )

XBROWSER("XXX" )

CLOSE XXX
al correo le envie las 2 tablas : prueba.dbf con estructura nuevo (+ autoincrement)
y prueba_.dat estructura vieja--

Gracias

Nota: probado con harbour y xharbour
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Wed Oct 22, 2025 12:17 AM

Enrico... ya revise....

El problema es con xharbour--- comercial y .org

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Wed Oct 22, 2025 07:40 AM

I don't understand. Can you describe the problem, please? I'll try to fix xHarbour but I need a clear explanation of the problem.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Wed Oct 22, 2025 08:11 AM
This is a sample. Without ZAP the autoinc field starts from 1, with ZAP it starts from 0. With Harbour it starts from 1 in both cases. Is this the problem? Please confirm.
#include "Fivewin.ch"


FUNCTION MAIN()

    DBCREATE( "PRUEBA.DBF", { { "TEST", "+", 4, 0 } } )

    USE PRUEBA EXCLUSIVE

//    ZAP

    APPEND BLANK
    APPEND BLANK

    CLOSE

    XBROWSER( "PRUEBA.DBF" )

    RETURN NIL
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Wed Oct 22, 2025 01:08 PM
Buen dia...

En definitiva.. el error es solo con xharbour.org / .com


Situacion 1 :
Append Blank + zap o sin zap, al repetir las compilaciones, a veces inicia en 1 y otras en cero

FERASE("F:\ZERUS\00\BASES\prueba.dbf")
CreaDbfConsumosX("F:\ZERUS\00\BASES\prueba.dbf" )

DBUSEAREA(.T.,"DBFCDX","F:\ZERUS\00\BASES\prueba.dbf","XXX",.F.) // exclusive

SELECT XXX

// zap
append blank

DBCOMMIT()

XBROWSER("XXX" )

CLOSE

Situacion 2 : Append From + zap o sin zap, al repetir las compilaciones, a veces inicia en 1 y otras en cero, pero tambien genera este error :

Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20150726)
FiveWin Version : FWH 24.09
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 13 secs
Error occurred at: 10/22/2025, 07:50:36
Error description: Error DBFCDX/1020 Error de tipo de datos: ID

Stack Calls :
===========
Called from: => __DBAPP( 0 )
Called from: FUENTES\GESTION\PRODUCCION\PRODCAPT.PRG => A_PRODCAPT_CAPTURA_( 691 )


FERASE("F:\ZERUS\00\BASES\prueba.dbf")
CreaDbfConsumosX("F:\ZERUS\00\BASES\prueba.dbf" )

DBUSEAREA(.T.,"DBFCDX","F:\ZERUS\00\BASES\prueba.dbf","XXX",.F.) // exclusive

SELECT XXX
// zap
// tabla con datos a migrar ... no tiene el campo ID (+)
append from "F:\ZERUS\00\BASES\prueba_.DBF" // linea 691

DBCOMMIT()

XBROWSER("XXX" )

CLOSE

//***************************

FUNCTION CreaDbfConsumosX(cFilCon )

LOCAL GetList := {} // Variable del sistema

LOCAL aDbfPag := {{"CCODMODEMP" ,"C",01,0},;
{"CNITASOEMP" ,"C",20,0},;
{"CNITEMPEMP" ,"C",20,0},;
{"CCODIGOEMP" ,"C",10,0},;
{"CNOMBREEMP" ,"C",70,0},;
{"NCONDIAEMP" ,"N",18,0},;
{"NCONM01EMP" ,"N",10,0},;
{"NCONM02EMP" ,"N",10,0},;
{"NCONM03EMP" ,"N",10,0},;
{"NCONM04EMP" ,"N",10,0},;
{"NCONM05EMP" ,"N",10,0},;
{"NCONM06EMP" ,"N",10,0},;
{"NCONM07EMP" ,"N",10,0},;
{"NCONM08EMP" ,"N",10,0},;
{"NCONM09EMP" ,"N",10,0},;
{"NCONM10EMP" ,"N",10,0},;
{"NCONM11EMP" ,"N",10,0},;
{"NCONM12EMP" ,"N",10,0},;
{"CFECCREEMP" ,"C",10,0},;
{"PROCESADO" ,"C",10,0},;
{"ID" ,"+",4,0}}


*>>>>FIN DECLARACION DE VARIABLES

*>>>>CREACION DE LA ESTRUCTURA

TRY
DBCREATE(cFilCon,aDbfPag,"DBFCDX")
CATCH
_ALERTA("Error. Creando tabla de consumos DIAN")
return .f.
END

RETURN .t.

*>>>>FIN CREACION DE LA ESTRUCTURA


RETURN
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Wed Oct 22, 2025 01:57 PM

Buen dia...

Con la actualizacion de xharbour.org publicada hoy oct 22/2025, ya inicia en 1 cuando se hace un append blank, pero con append from sigue generando el error:

Compiler version: xHarbour 1.3.2 Intl. (SimpLex) (Build 20251022)

FiveWin version: FWH 24.10

C compiler version: Borland/Embarcadero C++ 7.7 (32-bit)

Windows 11 64 Bits, version: 6.2, Build 9200

Time from start: 0 hours 0 mins 0 secs

Error occurred at: 10/22/25, 08:53:07

Error description: Error DBFCDX/1020 Data type error: ID

Stack Calls

===========

Called from: => __DBAPP( 0 )

Called from: RUSSOFT_ELECTRO_DIAN.prg => MAIN( 710 )

DBUSEAREA(.T.,"DBFCDX","F:\ZERUS\00\BASES\prueba.dbf","XXX",.F.)

SELECT XXX

append from "F:\ZERUS\00\BASES\prueba_.DBF" // linea 710

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CAMPO AUTOINCREMENT - DBF
Posted: Wed Oct 22, 2025 02:40 PM
Please try this sample. It works fine here. Change it to reproduce the problem.
#include "Fivewin.ch"


FUNCTION MAIN()

    DBCREATE( "PRUEBA1.DBF", { { "TEST", "+", 4, 0 } } )
    DBCREATE( "PRUEBA2.DBF", { { "TEST", "+", 4, 0 } } )

    USE PRUEBA1

    APPEND BLANK
    APPEND BLANK

    CLOSE

    USE PRUEBA2

    APPEND FROM PRUEBA1

    CLOSE

    XBROWSER( "PRUEBA2.DBF" )

    RETURN NIL