Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
No rule to drop
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00472138
Message ID:
00472227
Vues:
30
>
>ALTER TABLE MyTableName ;
>ALTER COLUMN PROPID I NULL ;
>ALTER COLUMN SITEID I NULL ;
>ALTER COLUMN SITEID2 I NULL ;
>ALTER COLUMN ASSRID I NULL ;
>ALTER COLUMN TRANID I NULL ;
>ALTER COLUMN MISCID I NULL ;
>ALTER COLUMN CREDID I NULL ;
>ALTER COLUMN COMPLEVL C (1) NULL ;
>ALTER COLUMN COMPLEVL DROP CHECK  ;
>ALTER COLUMN SOURCE C (1) NULL ;
>ALTER COLUMN SOURCE DROP CHECK  ;
>ALTER COLUMN PREFCODE C (1) NULL ;
>ALTER COLUMN SITESRCE C (1) NULL ;
>ALTER COLUMN CCODE C (2) NULL ;
>ALTER COLUMN TOWN C (4) NULL
>
>
>Nadya,
>
>Try adding the highlighted line at the beginning

Jim,

No, this is not the problem (I just forgot to show the full syntax, this part was in the command). I found, that ALTER COLUMN SOURCE NULL ALTER COLUMN SOURCE DROP CHECK works fine, but if I insert C (1) before NULL, it gives me this error message.

I'm trying to programmatically change the structure of my table. The correct definition of each field is in the DataDict table, I compare current table structure with the structure, definied in DataDict. I got the error, I mentioned.
This is an extract from my program. Could you please tell me, what's wrong?:
                                        wait window nowait ;
                                             "Please, wait while structure in "+lcTableName+" is checked..."
                                        set message to "Please, wait while structure in "+lcTableName+" is checked..."
                                        lcFieldName = upper(alltrim(DataDict.Field_Name))
                                        lnField=ascan(laFields, lcFieldName) && Seek Field Name

                                        if lnField>0
                                             lnField=asubscript(laFields, lnField, 1) && Return row
                                        endif
                                        lcCommand=""
                                        lbChange=.f.
* nsl 5/26/00 Needed to add separate command to drop validation because alter table does
* not like mix and match.
                                        lcvCommand=""
                                        lbvChange=.f.

                                        do case
                                        case lnField=0 && New field
                                        lcWholeLogStr= lcWholeLogStr+ ;
                                                       iif(llSomethingChanged,chr(13),"")+ ;
                                                       " - New field: "+lcFieldName
                                         llSomethingChanged=.t.                                                  
                                          wait window nowait ;
                                                  "In the table " +lcTableName+ chr(13)+;
                                                  "from Database " + taDBC[lni]+ chr(13)+;
                                                  "the field "+ lcFieldName +" is added now"
* NSL 5/11/00 - Remove the alter table tablename part because it is added when macro executed.
                                             lcCommand=;
                                                  " ADD COLUMN " + lcFieldName + " "+ Field_Type
                                             lbChange=.t. && Need to add
* Save the new field name
                                             lnAddFlds=lnAddFlds+1
                                             dimension AddFlds[lnAddFlds] && Re-dimension array
                                             AddFlds[lnAddFlds]=lcFieldName

                                        case Field_Type<>laFields[lnField,2]
* NSL 5/11/00 Eliminate message box - we don't want to hold up this process
                                             lbChange=.t.
                                             wait window nowait ;
                                                  "In the table " +lcTableName+ chr(13)+;
                                                  "from Database " + taDBC[lni]+ chr(13)+;
                                                  "the field "+ lcFieldName +" is changed now" +chr(13)+;
                                                  "because the field type is different"
                                        lcWholeLogStr= lcWholeLogStr+ ;
                                                       iif(llSomethingChanged,chr(13),"")+ ;
                                                       " -  Field: "+lcFieldName+" type was changed"
                                                       llSomethingChanged=.t.                                                       

                                        case  Field_Null<>laFields[lnField,5]
                                             lbChange=.t.
                                             wait window nowait ;
                                                  "In the table " +lcTableName+ chr(13)+;
                                                  "from Database " + taDBC[lni]+ chr(13)+;
                                                  "the field "+ lcFieldName +" is changed now" +chr(13)+;
                                                  "because the field Null is different"
                                        lcWholeLogStr= lcWholeLogStr+ ;
                                                       iif(llSomethingChanged,chr(13),"")+ ;
                                                       " -  Field: "+lcFieldName+" Null was changed"
                                                       llSomethingChanged=.t.                                                       
                                    llNullChanged=.t.
                                        case  inlist(Field_Type,"C","M") and Field_Nocp<>laFields[lnField,6]
                                             lbChange=.t.
                                             wait window nowait ;
                                                  "In the table " +lcTableName+ chr(13)+;
                                                  "from Database " + taDBC[lni]+ chr(13)+;
                                                  "the field "+ lcFieldName +" is changed now" +chr(13)+;
                                                  "because the field Nocptrans is different"
                                                 lcWholeLogStr= lcWholeLogStr+ ;
                                                       iif(llSomethingChanged,chr(13),"")+ ;
                                                       " -  Field: "+lcFieldName+" Nocptrans was changed"
                                                       llSomethingChanged=.t.                                                       


                                        case  upper(alltrim(Field_Defa))<>upper(alltrim(laFields[lnField,9]))
                                             lbChange=.t.
                                             wait window nowait ;
                                                  "In the table " +lcTableName+ chr(13)+;
                                                  "from Database " + taDBC[lni]+ chr(13)+;
                                                  "the field "+ lcFieldName +" is changed now" +chr(13)+;
                                                  "because the field default is different"
                                                  lcWholeLogStr= lcWholeLogStr+ ;
                                                       iif(llSomethingChanged,chr(13),"")+ ;
                                                       " -  Field: "+lcFieldName+" Default Value was changed"
                                                       llSomethingChanged=.t.                                                       


                                        case  inlist(Field_Type,"C","N","F","B") and ;
                                                  (Field_Len<>laFields[lnField,3] or;
                                                  Field_Dec<>laFields[lnField,4])
                                             lbChange=.t.
                                             wait window nowait ;
                                                  "In the table " +lcTableName+ chr(13)+;
                                                  "from Database " + taDBC[lni]+ chr(13)+;
                                                  "the field "+ lcFieldName +" is changed now "+chr(13)+;
                                                  "because field len was changed..."
                                                 lcWholeLogStr= lcWholeLogStr+ ;
                                                       iif(llSomethingChanged,chr(13),"")+ ;
                                                       " -  Field: "+lcFieldName+" length was changed"
                                                       llSomethingChanged=.t.                                                       
                                        llLenChanged=.t.
                                        endcase
* NSL 5/15/00 Added the check for lbChange back in - we do not want to alter table unless needed.
* NSL 5/15/00 I removed the lbchange flag here because we need the alter column code
*                    We will not use it if we do not have a lbchange flag later.
                                        if empty(lcCommand) &&and lbChange && Removed and lbChange PKP Jan 2000 need to check Validation at all times
* NSL 5/11/00 - Remove the alter table tablename part because it is added when macro executed.
                                             lcCommand= ;
                                                  " ALTER COLUMN " + lcFieldName + iif(llNullChanged," "," "+ DataDict.Field_Type)
                                        endif

* -- Add in the field length
                                        do case
                                        case inlist(DataDict.Field_Type,"D","T","I","Y","L","M","G","P")
** Don't need to specify field len
                                        case DataDict.Field_Type="C" && Character
                                             lcCommand=lcCommand+iif(llLenChanged," ("+transform(DataDict.Field_Len)+")","")
                                        case inlist(DataDict.Field_Type,"N","F","B") && Numeric, or Floating, or Double
                                             lcCommand=lcCommand+ iif(llLenChanged, ;
                                                  " ("+transform(DataDict.Field_Len)+","+;
                                                  transform(DataDict.Field_Dec)+")","")
                                        endcase
                                        if DataDict.Field_Null
                                             lcCommand=lcCommand+iif(llNullChanged," NULL","")
                                        else
                                             lcCommand=lcCommand+iif(llNullChanged," NOT NULL","")
                                        endif
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