Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #5814 > unrolled thread

Problem when I change the type of a field in a database

Started byBGeorge <GeorgeTritsos@yahoo.gr>
First post2013-09-07 23:35 -0700
Last post2013-09-08 14:03 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Problem when I change the type of a field in a database BGeorge <GeorgeTritsos@yahoo.gr> - 2013-09-07 23:35 -0700
    Re: Problem when I change the type of a field in a database Massimo Bighelli <info@arcasistemi.it> - 2013-09-08 11:45 +0200
    Re: Problem when I change the type of a field in a database D.J.W. van Kooten <public@ic2remove.this.com> - 2013-09-08 14:03 +0200

#5814 — Problem when I change the type of a field in a database

FromBGeorge <GeorgeTritsos@yahoo.gr>
Date2013-09-07 23:35 -0700
SubjectProblem when I change the type of a field in a database
Message-ID<fde630fe-3a99-4a5a-8286-72019f896e21@googlegroups.com>
Hi all,

I have a problem when i change the type of a field in a database.
e.g.
MyDataBaseFile.DBF
FieldName   Type    Width
FirstField  Numeric 2
SecondField Memo
after change
FirstField  Numeric 2
SecondFiled String  20

in template file i put my changes

My code:
sourcefile:="MyDataBaseFile.DBF"
mfile1:=sourcefile+".DBF"
mfile2:=sourcefile+".OLD"
FRename(mfile1,mfile2)
create &msourcefile from template
append from &mfile2 // here is the error
erase &mfile2

Error message:
--------------
Error Code:  34 [ DATA WIDTH ERROR ]
Subsystem: DBFNTX
Error Subcode: 1121 (Datawidth error)
Function: DBAPP
Requested type: NUMERIC
CallStack: 
DBASE:PUSHBUTTON2 (Line: 62)
DIAXDBASE:PUSHBUTTON3 (Line: 7)
APP:START (Line: 35)

Error Object created:
--------------------
SubSystem       :DBFNTX
SubCode         :      1121
GenCode         :Data width error
OsCode          :         0
ArgType         :NIL
FuncPtr         :0x00000000
ArgNum          :         0
FuncSym         :DBAPP
Severity        :         2
CanDefault      :.T.
CanRetry        :.F.
CanSubstitute   :.F.
Operation       :
Description     :
FileName        :
Tries           :         1
FileHandle      :         0
SubCodeText     :Datawidth error
Arg             :
ArgTypeReq      :NUMERIC
MaxSize         :         0
SubstituteType  :NIL
CallFuncSym     :
--------------------

George

[toc] | [next] | [standalone]


#5815

FromMassimo Bighelli <info@arcasistemi.it>
Date2013-09-08 11:45 +0200
Message-ID<l0hh0d$ugv$1@speranza.aioe.org>
In reply to#5814
George,

if you are with DBFNTX driver, you have the DBT file too, because of the 
memo field

Massimo

Il 08/09/2013 08:35, BGeorge ha scritto:
> Hi all,
>
> I have a problem when i change the type of a field in a database.
> e.g.
> MyDataBaseFile.DBF
> FieldName   Type    Width
> FirstField  Numeric 2
> SecondField Memo
> after change
> FirstField  Numeric 2
> SecondFiled String  20
>
> in template file i put my changes
>
> My code:
> sourcefile:="MyDataBaseFile.DBF"
> mfile1:=sourcefile+".DBF"
> mfile2:=sourcefile+".OLD"
> FRename(mfile1,mfile2)
> create &msourcefile from template
> append from &mfile2 // here is the error
> erase &mfile2
>
> Error message:
> --------------
> Error Code:  34 [ DATA WIDTH ERROR ]
> Subsystem: DBFNTX
> Error Subcode: 1121 (Datawidth error)
> Function: DBAPP
> Requested type: NUMERIC
> CallStack:
> DBASE:PUSHBUTTON2 (Line: 62)
> DIAXDBASE:PUSHBUTTON3 (Line: 7)
> APP:START (Line: 35)
>
> Error Object created:
> --------------------
> SubSystem       :DBFNTX
> SubCode         :      1121
> GenCode         :Data width error
> OsCode          :         0
> ArgType         :NIL
> FuncPtr         :0x00000000
> ArgNum          :         0
> FuncSym         :DBAPP
> Severity        :         2
> CanDefault      :.T.
> CanRetry        :.F.
> CanSubstitute   :.F.
> Operation       :
> Description     :
> FileName        :
> Tries           :         1
> FileHandle      :         0
> SubCodeText     :Datawidth error
> Arg             :
> ArgTypeReq      :NUMERIC
> MaxSize         :         0
> SubstituteType  :NIL
> CallFuncSym     :
> --------------------
>
> George
>


*Massimo Bighelli* ARCA Sistemi S.r.l.

[toc] | [prev] | [next] | [standalone]


#5816

FromD.J.W. van Kooten <public@ic2remove.this.com>
Date2013-09-08 14:03 +0200
Message-ID<jdpo29p7l0o51ch0feej5tdcsgmd4ij9il@4ax.com>
In reply to#5814
On Sat, 7 Sep 2013 23:35:46 -0700 (PDT), BGeorge
<GeorgeTritsos@yahoo.gr> wrote:

Hello George,
>
>I have a problem when i change the type of a field in a database.
>e.g.


I doubt if you can do that kind of changes with append from. 


I use several function to copy content, with some modifications you
should be able to do the job:


FUNCTION CopyFieldContent(oDBFrom AS OBJECT,nFromRec AS FLOAT,oDBTo AS
OBJECT,nToRec AS DWORD) AS LOGIC PASCAL
//#s General function to copy a record content from record nFromrec of
oDBFrom to nTorec of oDBTo db 16-04-2007
//#s
//#x
//#l Strong typed 7-11-2009
//#l This function does NOT copy memofields
//#l
//#l
//#p
//#p
//#r
//#e
//#e	
LOCAL ni,nFieldPos AS DWORD
LOCAL cVeldNaam AS STRING
LOCAL lWritten AS LOGIC
LOCAL nFields AS DWORD

	lWritten:=FALSE // Init: nothing written
	oDBFrom:GoTo(nFromRec) // Go to requested record
	nFields:=oDBFrom:FCOUNT
	FOR ni:=1 UPTO nFields // go through field of origing
		cVeldNaam:=oDBFrom:FieldName(ni) // get fieldname of
position now checked
		nFieldPos:=oDBTo:FieldPos(cVeldNaam) // where is it in
copy database
		IF nFieldPos>0 // If found
			oDBTo:FIELDPUT(nFieldPos,oDBFrom:FIELDGET(ni))
// write info in found position
IF ValType(oDBFrom:FIELDGET(ni))="N"
	// if the target field is C you can use STR, same checks and
adaptions for memo->string etc.
ENDIF
			lWritten:=TRUE // Something was written
		ENDIF
	NEXT
// 	oDBTo:commit() // For loops, it's better not to commit here 
// 	oDBTounlock()
RETURN lWritten 

Dick

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web