Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete a record (syntax)

Status
Not open for further replies.

KingSlick

Programmer
Mar 9, 2007
45
US
Ok, I have a .dbf that I would like to delete some records out of it. The problem is that I need for it to remove based on several different strings that appear in the different fields.

I have the following below that keeps giving me errors...

Code:
delete for LOWER(laSortingOrder[zz,1]) $ LOWER(source) AND LOWER(laSortingOrder[zz,3]) $ LOWER(source) AND NOT LOWER(laSortingOrder[zz,1]) $LOWER(source)

any help would be great. Thanks in advance
 
Did you have any index based on "source" field?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 

What error message do you get?

And it seems that you want
LOWER(laSortingOrder[zz,1]) $ LOWER(source)
and
NOT LOWER(laSortingOrder[zz,1]) $ LOWER(source)
to be true at the same time?
 
sorry about that, the not should be

Code:
NOT LOWER(laSortingOrder[zz,1]) + "0]" $LOWER(source)

error message is:
Command contains unrecognized phrase/keywords

Thanks
 

Are you showing the exact code that you have, as it appears in your program?

Can you please post an exact piece of code, with all the semicolons (if any), line breaks, and all other necessary info?




 
delete for (LOWER(laSortingOrder[zz,1]) $ LOWER(source) OR LOWER(laSortingOrder[zz,3]) $ LOWER(source)) AND NOT LOWER(laSortingOrder[zz,1]) $ LOWER(source)

Your delete command is wrong. You can not delete for LOWER(laSortingOrder[zz,1]) $ LOWER(source) and NOT LOWER(laSortingOrder[zz,1]) $ LOWER(source) in the same time.

Can you describe your criteria for deletion in English?
 

markros,

See KingSlick's above post with the correction of the criteria.

 
In other words:

"something" $ lower(order) and not "something0]" $ lower(order)

It should work, but I'm thinking, how to simplify this criterion.
 
Code:
Delete For LOWER(laSortingOrder[zz,1]) $ LOWER(source) AND LOWER(laSortingOrder[zz,3]) $ LOWER(source) AND NOT LOWER(laSortingOrder[zz,1]) + "0]" $LOWER(source)
...compiles without errors. Seems you didn't copy & paste the code exactly as it is. Even the missing space after the last $ does work, at least in vfp9.

Bye, Olaf.
 
KingSlick,

I'm sorry if this is stating the obvious, but have you got a semi-colon at the end of the first two lines? These do not appear in the code you posted.

Without the semi-colons, the first line will give the error you described.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

such things can of course be the reason, I do have that same error but I emtered and compiled this as a single line.

Bye, Olaf.
 

Mike Lewis,

I think that the code posted here is not the exact code that is used. The criteria had operand "0]" missing, so the the code was probably edited for the post. That's why I asked KingSlick to post the exact code with all the punctuation. Missing semicolons or something to that effect was my first thought, too.

Olaf,

I tried it as a single line, too, and just substituted the field name Source by another field name from a real table I had open - no error. Then I created a test table, with a field named source - still no error. VFP6 here. I guess, we need to see the exact code, semicolons could be the problem.
Or, possibly, the contents of laSortingOrder array.

Mike Yearwood,

Single quote and double quote are string delimiters, too, but you can always use them inside the string if the string is surrounded by a pair of different delimiters.
Anyway, I tried, and compiler doesn't have a problem with "0]". Actually, I use an opposite of it for years, and it works.

I use it like this:

theList=["First Item","Second Item","Third Item"]
DELETE FOR INLIST(&theList)
SELECT item FROM Something WHERE item IN (&theList)

 
KingSlick
Could you run the following 3 lines of code on your data and tell us the results ?

delete for LOWER(laSortingOrder[zz,1]) $ LOWER(source)
delete for LOWER(laSortingOrder[zz,3]) $ LOWER(source)
delete for NOT LOWER(laSortingOrder[zz,1]) + "0]" $ LOWER(source)


David W. Grewe Dave
 
Actually I didn't scroll all the way over and there was "INTO TABLE" at the end of the line. Once removed, it worked fine. Thanks for all the help though
 
Please make me feel like more of an ass!!

Yes, I know, I can be an idiot
 
KingSlick:
I am sorry if I have offended you, it was Not my intention…
People here will go out of their way to help and this was probably the first time that a poster did not check the complete code…which kind of threw everybody into a loop… But, believe me I have done worse…Just thought it was hilarious…
 
Imaginecorp,

I wasn't offended, I found it rather funny also. Sorry if I made you think that.
 
dgrewe, I think you meant SELECT instead of DELETE. Or at least you should preceed this with a backup warning :)

And the first delete command actually eliminates the third.
 
Dave your three deletes would be like a single one with ORed conditions...

Okay glad the spook came to a unmythical explaination :).

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top