Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reproducible C5 Error
Message
 
 
À
19/03/2002 09:56:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00634446
Message ID:
00634558
Vues:
16
Will,

You can not change field, which is part of index without deleting this index first. Here is the piece of code, which works for me in VFP6 SP4: (thanks to Trey Walpole for the idea)
********************************************************************
*  Description.......: ChangeTable - run alter command
*  Calling Samples...:
*  Parameter List....: tcTableName, tcCommandStr
*  Created by........: Nadya Nosonovsky 06/06/2001 10:16:59 AM (idea by Trey Walpole)
*  Modified by.......:
********************************************************************
lparameters tcTableName, tcCommandStr
local lcOldError, llError, lcTag
lcOldError=on('error')
on error llError=.t.
* invoke the ALTER TABLE – SQL Command with &-macro expanded tail
alter table (m.tcTableName) &tcCommandStr novalidate
do while m.llError and oValid.lContinue
	release laError
	=aerror(laError)
	if laError[1,1] = 1531 && cannot alter table because of index
	   	lcTag = laError[1,3]
		set message to 'Deleting tag '+ m.lcTag
		delete tag (m.lcTag)
		llError = .f.
		alter table (m.tcTableName) &tcCommandStr novalidate
	else
		exit
	endif
enddo
if m.llError
** Exited
	aerror(laError)
	=messagebox("Error: " + transform(laError[1,1])+chr(13)+laError[1,2], 48,"Alter table error")
endif
*set message to ' '			&& clear status bar msg.
on error &lcOldError
return m.llError
>Hello all,
>
>I have recently been getting a lot of C5 errors when altering the structure of tables and think I have found the problem.
>
>When I try and run the following command in a loop I get a C5
>
>Alter table x alter column y n(3)
>
>The problem occurs when the field y is used in an index
>I have a few indexes which look like : field1 + str(y) + field3
>these seem to cause the most trouble.
>
>Has anyone else encountered anything like this?
>My workaround is to delete tag all & recreate but its a bit of a pain!
>
>Thanks
>
>Will
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform