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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DO CASE....

Status
Not open for further replies.

stlrain95

Programmer
Sep 21, 2001
224
US
I am trying to replace several fields meeting certain criteria.

DO CASE
CASE PTYPE='1440'
REPLACE TYPE929 WITH 'FACTR' FOR !EOF()
ENDCASE

This doesn't seem to be working, suggestions?
 
Try this instead:
[tt]
REPLACE TYPE929 WITH 'FACTR' FOR PTYPE='1440'
[/tt]
Ian
 
HI
If I undersatnd that you want to replace the field in multiple records, then the code shall be..

REPLACE ALL [COLOR=/]TYPE929 WITH 'FACTR' FOR PTYPE='1440'

Hope this helps you :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
You could also use this update-sql command:

update (DatabaseName!TableName) set TYPE929 = 'FACTR' where PTYPE = '1440'

this would also work.

Dave Long
 
This is not replacing all of the fields with the above criteria?
 
Both my code and Ramani's will replace the TYPE929 field with "FACTR" for every record that has PTYPE='1440'. (The REPLACE command has an implicit ALL when you use a FOR clause.)

I believe Dave's would work as well, although I haven't used the SQL Update command myself.

Did you try the suggestions? Did they not work? What DID happen?

Ian
 
When I used the REPLACE command exclusively without a CASE statement, they work. Inside a CASE statement they didn't work.

 
Check to see if you filtered your data prior to issuing your case statement.
 
Can I do this.

DO CASE
CASE SET FILTER TO '1440'$PTYPE
REPLACE ALL TYPE929 WITH 'FACTR' FOR PTYPE='1440'
ENDCASE
????
 
No, but this might work:
DO CASE
CASE SET("FILTER") == "'1440'$PTYPE"
REPLACE ALL TYPE929 WITH 'FACTR' FOR PTYPE='1440'
ENDCASE

Rick
 
Ack...ok, I think I see where your problem is.

Why are you using CASE at all? Just use the REPLACE statement I mentioned above all by itself. That will scan through the table for any records that have PTYPE='1440' and replace field TYPE929 with 'FACTR' in each. No CASE or loop of any kind required.

Ian
 
Thank you everyone. I agree there is no reason to use the CASE statement.

Appreciate the help.

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top