how to retrieve data from database and compare it if there is a match using IF ELSE. VFP 9

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

  •  15-10-2022
  •  | 
  •  

문제

how to compare if the data is already exists in database in foxpro 9. IF(if found) employee already exist. ELSE insert employee into database.

올바른 솔루션이 없습니다

다른 팁

Your question is too vague on "already exists". What if you are looking for an employee "John Smith" and coincidentally you are a large organization where there are SEVERAL "John Smith" names employed... Do you have other criteria? Such as a social security number, date of birth info, etc? If so, you could run a query something like.

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" ) 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top