2014-02-22 19 views

回答

0

你的問題太籠統的「已存在」。如果你正在尋找一名員工「約翰史密斯」,並且巧合的是你是一個大型組織,那裏有幾個「約翰史密斯」的名字......你有其他標準嗎?如社會安全號碼,出生日期信息等?如果是這樣,你可以運行一個類似的查詢。

lookForSSN = "123-45-6789" 
use in select("C_IsOnFile") 
select SomeIDColumn ; 
    from YourEmployeeTable ; 
    where SocSecNum = lookForSSN; 
    into cursor C_IsOnFile 

if reccount("C_IsOnFile") = 1 
    */ Already on file, you can update it 
    update YourEmployeeTable; 
     set FirstName = FirstNameVar,; 
      LastName = LastNameVar,; 
      DoB = DoBVar,; 
      etc = etcVar; 
     where ; 
     SSN = lookForSSN 
else 
    */ Not on file, add it 
    insert into YourEmployeeTable ; 
     (FirstName, LastName, DoB, SSN, etc); 
     values; 
     (FirstNameVar, LastNameVar, DoBVar, lookForSSN, etcVar) 

endif 
*/ close temp cursor when finished 
use in select("C_IsOnFile") 
相關問題