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

REPLACE command not working...arrgh LOL

Status
Not open for further replies.

foxup

Programmer
Dec 14, 2010
328
CA
Hi,

I want to do a simple replace but it's not working at all. It's giving me a "Function Name is Missing )" error.

Am I missing something?

Here is the command I'm using:


REPLACE SRCTEL1 WITH ALLTRIM(FRCITY) FOR AMOUNT_REM IN (SELE REMARK FROM REMARKS WHERE SRVGRPID='HOS')




Please help.


Thanks,
FOXUP
 
You cannot mix REPLACE with SQL.

VFP therefore assumes IN is an array and expects SELE to be a variable with an array index and a ) missing after it.

You either set a relation from the table you want to replace in to the Remarks table and filter FOR !EOF("REMARKS") or you make an UPDATE-SQL out of this like:

Code:
UPDATE yourtable SET SRCTEL1 = ALLTRIM(FRCITY);
 WHERE AMOUNT_REM IN (SELE REMARK FROM REMARKS WHERE SRVGRPID='HOS')

Bye, Olaf.
 
I don't think this syntax is even allowed - but I am not sure about VFP9, as we are still using VFP6. REPLACE...FOR... is a scope command, and SELECT is an SQL statement. Usually, they don't mix. FOR clause doesn't allow an SQL sub-SELECT the way you would do it in a SELECT's WHERE clause.

At least in VFP6, I do what you want to do in two steps:
Code:
SELECT REMARK FROM REMARKS ;
       WHERE SRVGRPID='HOS' INTO ARRAY aRamark
REPLACE SRCTEL1 WITH ALLTRIM(FRCITY) ;
       FOR ASCAN(aRamark,AMOUNT_REM)>0 IN myTable

Please someone who works in VFP of higher versions correct me if a syntax foxup showed is allowed now.
 
Hi Olaf,

Does your UPDATE command equivalate whaat my "REPLACE" command? Do they do the same thing?

Please confirm.

Thanks,
FOXUP
 

Olaf, you beat me to this - and with a better idea of using UPDATE-SQL.
 
OK, thanks guys. It works beatifully. Thanks again.
 
Yes this is it's intention, to replace the REPLACE command.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top