How is it possible that this select statement works, but this update statement does not in VFP 9?

StackOverflow https://stackoverflow.com/questions/14593389

  •  06-03-2022
  •  | 
  •  

質問

Overview

I am trying to write a select statement in Visual Fox Pro 9 (VFP9) to update a row (and eventually several other records, I wrote a select statement first and it worked great, I got the expected result.

But I'm a little new to VFP9 syntax, and who wouldn't be in 2013? I'm expecting the UPDATE which contains my select to operate a bit like an UPDATE INNER JOIN in actual non-foxprose SQL.

My select statement, it works fine.

SELECT temptable3.constate FROM temptable3, prw22001 ;
  WHERE prw22001.empno = temptable3.empno AND temptable3.pssn = prw22001.ssn AND temptable3.empno='5202' AND temptable3.constate <> prw22001.stateid AND prw22001.procyear='2012'

My Update statement (which contains my select statement and doesn't work):

UPDATE prw22001 ;
  SET prw22001.stateid = SELECT temptable3.constate FROM temptable3, prw22001 ;
  WHERE prw22001.empno = temptable3.empno AND temptable3.pssn = prw22001.ssn AND temptable3.empno='5202' AND temptable3.constate <> prw22001.stateid AND prw22001.procyear='2012'

I get an error that reads Microsoft Visual FoxPro Command contains unrecognized phrase/keyword. I don't see what it is talking about and a good 4/5ths of my query is my original select statement.

役に立ちましたか?

解決

convert your statement like this:

UPDATE prw22001 ;
  SET prw22001.stateid = temptable3.constate ;
  FROM temptable3, prw22001 ;
  WHERE prw22001.empno = temptable3.empno AND temptable3.pssn = prw22001.ssn AND temptable3.empno='5202' AND temptable3.constate <> prw22001.stateid AND prw22001.procyear='2012'
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top