Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop Column - complicated problem
Message
 
 
To
04/12/2000 14:23:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00447719
Message ID:
00449016
Views:
14
Trey,

I undesrtand that. I even tried your test program! :) But then I did the same in the ModifyStructure program (DeleteFields is a procedure in this program), it shows LAERROR as a tag name. This is weird and I can not find the source of the problem. What's why I asked you to take a look at the code. May be I just overlooked something basic...

>Nadya,
>
>I'm not quite sure I understand the question.
>laError[1,2] has the full message
>laError[1,3] has the inserted member of the messsage, i.e., MESSAGE(1) - for this error, that should be just the tag name.
>
>
>Hi Trey,
>>
>>For some reason, I could not make your idea to work. It returns LAERROR as laError[1,3] and shows it in laError[1,2] also. Something's strange. Perhhaps, you can find an error in the code bellow:
>>
>>
>>***********************************************************************************
>>procedure DeleteFields
>>*--------------------------------------------------------------------------
>>* -- RMM: 05/23/00
>>* --     This procedure compares the current table's fields with the fields in the
>>* --          datadict.
>>* --     If fields are found in the current table and not in the datadict, then assume
>>* --          we need to delete these fields ...
>>* --     This procedure is called before we do the modify (alter table) commands
>>*--------------------------------------------------------------------------
>>lparameters tcTableName
>>local lnOldSelect, lcCommandDel, lnCount, lcMessDel, lcMessDelIndx, ;
>>     lcOldError, llError, lcTag, lcOldMessage, llDel
>>lnOldSelect=select()
>>if !oValid.lContinue && Don't continue
>>     return
>>endif
>>create cursor oldTab (FldName C(128))
>>insert into oldTab from array laFields && Array of fields in a table
>>** Find fields, which should be deleted
>>store '' to lcCommandDel, lcMessDel, lcMessDelIndx
>>select * ;
>>     from oldTab ;
>>     where FldName not in ;
>>     (select Field_Name from DataDict where &tcTableName>0) ;
>>     into cursor curTemp
>>
>>if _tally > 0
>>     select curTemp
>>     scan
>>          if !oValid.lContinue
>>               return
>>          endif
>>          lcCommandDel =lcCommandDel+ " DROP COLUMN " + lower(alltrim(curTemp.FldName))
>>          lcMessDel=lcMessDel+alltrim(curTemp.FldName)+','
>>     endscan
>>     suspend
>>     set message to 'Deleting fields: '+left(lcMessDel,len(lcMessDel)-1)
>>     =messagebox(lcCommandDel)
>>     lcOldError=on('error')
>>     on error llError = .t.
>>     alter table (tcTableName) &lcCommandDel
>>     do while llError
>>          =aerror(laError)
>>          if laError[1,1] = 1531 && cannot drop field because of index
>>               lcTag = laError[1,3]
>>               delete tag (lcTag)
>>               llError = .f.
>>               alter table (tcTableName) &lcCommandDel
>>          else
>>               exit
>>          endif
>>     enddo
>>     if llError
>>** Exited
>>          aerror(laError)
>>          =messagebox("Error: " + transform(laError[1,1])+chr(13)+;
>>               laError[1,2], 48)
>>     endif
>>     on error &lcOldError
>>     llDel=.t.
>>else && Tally=0 no fields to delete
>>     llDel=.f.
>>endif
>>* Close no longer needed tables
>>use in curTemp
>>use in oldTab
>>select (lnOldSelect)
>>return llDel
>>
>>Thanks a lot in advance.
>>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform