Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete for - deletes file
Message
From
09/05/2014 18:58:24
 
 
To
09/05/2014 18:21:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01599805
Message ID:
01599825
Views:
59
Many thanks Al good advice. Seems I am slowly migrating towards SQL commands anyway - not by choice - kicking and screaming all the way - but I do see the value and will make a more conscious effort towards that end.
thanks for the help and reassurances.
k

>Likely something else in your code or environment is the cause. With a lot of the native VFP record manipulation commands, by default you have to make sure you're working in the correct work area/alias. It's almost always better to use the alias instead of work area number e.g.
>
>SELECT MyDBF
>
>instead of
>
>SELECT 4
>
>In later versions of VFP you can mostly avoid problems with being in the wrong work area or alias by including the IN clause in your command - another good habit to get into e.g.
>
>DELETE FOR namet = "XTEST" IN MyDBF
>
>Your workaround of using DELETE - SQL is a good example of why it's often better to use the SQL commands rather than native xBASE, another good habit to get into, especially if in future you need to migrate to, or work with SQL database engines.
>
>If you're still interested in getting to the bottom of this, your best bet is probably to run your code in the Debugger and watch values while you trace.
>
>>timep.dbf is the name of the table
>>select 4
>>
>>>Just to be clear, you're saying the exact command(s) giving you trouble is
>>>
>>>Delete for namet = "XNAME"
>>>pack
>>>
Presumably "namet" is the name of a field in the currently selected DBF. What's the name of the DBF that's getting deleted? What's the currently selected table/alias when you issue the commands?
>>>
>>>>Yes that's the mystery Al.
>>>>as a temporary solution I have changed the command to
>>>>delete from mydbf where namet = "XNAME"
>>>>which seems to be holding up.
>>>>Delete for - is on my black list for now.
>>>>k
>>>>
>>>>
>>>>>Deleting the entire file should only happen if you issue DELETE FILE ... , i.e. the command starts with those two words in that order.
>>>>>
>>>>>In your first post, was the DELETE command exactly the same as the one giving you trouble? If the real command giving you trouble is different, what is it? Maybe it includes a reserved word (?)
>>>>>
>>>>>As I posted before it's possible DELETE FOR could delete all the records, then PACK would subsequently remove them. But that case should not entirely delete the file, just leave you a DBF with no records in it.
>>>>>
>>>>>>thanks Al
>>>>>>when I say deletes the file I don't mean deletes the records in the file - I mean the whole file went missing out of the directory.
>>>>>>it has happened twice with two different files (ie dbf tables). It's like it was reading the first word 'delete' and didn't bother with the rest of the command. So by the time it found the next line 'pack' there was no file left to pack.
>>>>>>
>>>>>>k
>>>>>>
>>>>>>
>>>>>>>>I am having an issue that has just suddenly surfaced
>>>>>>>>in programming when line reads
>>>>>>>>
>>>>>>>>Delete for namet = "XNAME"
>>>>>>>>pack
>>>>>>>>
>>>>>>>>
>>>>>>>>instead of deleting the records selected - VFP deletes the whole file.
>>>>>>>>
>>>>>>>>What's going on here?????? Halp!!!!
>>>>>>>
>>>>>>>If your field "NameT" is longer than 5 characters (the length of your search string), be aware of partial/inexact string matches. By default, SET EXACT is OFF in VFP.
>>>>>>>
>>>>>>>CLEAR
>>>>>>>
>>>>>>>CREATE CURSOR Test ;
>>>>>>>	( NameT C( 6 ) )
>>>>>>>
>>>>>>>INSERT INTO Test ( NameT ) VALUES ( "XTEST " )
>>>>>>>INSERT INTO Test ( NameT ) VALUES ( "XTEST2" )
>>>>>>>INSERT INTO Test ( NameT ) VALUES ( "XTEST3" )
>>>>>>>INSERT INTO Test ( NameT ) VALUES ( "XTEST4" )
>>>>>>>INSERT INTO Test ( NameT ) VALUES ( "XTEST5" )
>>>>>>>
>>>>>>>COUNT FOR NameT = "XTEST" TO Result1
>>>>>>>COUNT FOR NameT == "XTEST" TO Result2
>>>>>>>COUNT FOR NameT == "XTEST " TO Result3
>>>>>>>
>>>>>>>?Result1 && 5
>>>>>>>?Result2 && 0
>>>>>>>?Result3 && 1
>>>>>>>
>>>>>>>USE IN Test
>>>>>>>
Previous
Reply
Map
View

Click here to load this message in the networking platform