Heathbo Posted March 10, 2005 Author Posted March 10, 2005 I have a script that is used to import a record from one database to another(Database 1, Database 2). The script will first check to see if the record already exist in Database 2. If it does then it increases the number in a number field by 1. If it doesn't exist in Database 2 it imports the record from Database 1 to Database 2. The script I have now copies an ID # from Database 1. Then goes to Database 2, goes into find mode, paste the ID# in the ID field, and performs a find. If the Total record count > 0 it increases the number in a number field by 1. The problem I'm running into is, if there are no records found I need to import the file in from Database 1. But the script keeps ending after it doesn't find any records. Even if I click on continue. Any help you can give is much appreciated.
Heathbo Posted March 10, 2005 Posted March 10, 2005 I have a script that is used to import a record from one database to another(Database 1, Database 2). The script will first check to see if the record already exist in Database 2. If it does then it increases the number in a number field by 1. If it doesn't exist in Database 2 it imports the record from Database 1 to Database 2. The script I have now copies an ID # from Database 1. Then goes to Database 2, goes into find mode, paste the ID# in the ID field, and performs a find. If the Total record count > 0 it increases the number in a number field by 1. The problem I'm running into is, if there are no records found I need to import the file in from Database 1. But the script keeps ending after it doesn't find any records. Even if I click on continue. Any help you can give is much appreciated.
Heathbo Posted March 10, 2005 Author Posted March 10, 2005 I have a script that is used to import a record from one database to another(Database 1, Database 2). The script will first check to see if the record already exist in Database 2. If it does then it increases the number in a number field by 1. If it doesn't exist in Database 2 it imports the record from Database 1 to Database 2. The script I have now copies an ID # from Database 1. Then goes to Database 2, goes into find mode, paste the ID# in the ID field, and performs a find. If the Total record count > 0 it increases the number in a number field by 1. The problem I'm running into is, if there are no records found I need to import the file in from Database 1. But the script keeps ending after it doesn't find any records. Even if I click on continue. Any help you can give is much appreciated.
NYPoke Posted March 10, 2005 Posted March 10, 2005 Not sure what version you are running, but in general you use the following logic: Set Error Capture (ON) // Lets you trap that irritating error message Enter Find Mode ...Field Logic... Perform Find // 401 = No Records Found. FM Help has all the Error Codes if (Status (CurrentError) = 401) ... Do your alternate logic here else ... Do your normal logic here endif
NYPoke Posted March 10, 2005 Posted March 10, 2005 Not sure what version you are running, but in general you use the following logic: Set Error Capture (ON) // Lets you trap that irritating error message Enter Find Mode ...Field Logic... Perform Find // 401 = No Records Found. FM Help has all the Error Codes if (Status (CurrentError) = 401) ... Do your alternate logic here else ... Do your normal logic here endif
NYPoke Posted March 10, 2005 Posted March 10, 2005 Not sure what version you are running, but in general you use the following logic: Set Error Capture (ON) // Lets you trap that irritating error message Enter Find Mode ...Field Logic... Perform Find // 401 = No Records Found. FM Help has all the Error Codes if (Status (CurrentError) = 401) ... Do your alternate logic here else ... Do your normal logic here endif
SteveB Posted March 10, 2005 Posted March 10, 2005 Rather than mess with error codes, and have to try remembering them, I use STATUS(CurrentFoundCount)= 0 then my Find turned up nothing. Steve
SteveB Posted March 10, 2005 Posted March 10, 2005 Rather than mess with error codes, and have to try remembering them, I use STATUS(CurrentFoundCount)= 0 then my Find turned up nothing. Steve
SteveB Posted March 10, 2005 Posted March 10, 2005 Rather than mess with error codes, and have to try remembering them, I use STATUS(CurrentFoundCount)= 0 then my Find turned up nothing. Steve
MoonShadow Posted March 10, 2005 Posted March 10, 2005 Agreed Steve. Since Heathbo is using vs. 7, it would be: If [ not Get(FoundCount) ] ... which is same as If [ Get(FoundCount) = 0 ] ... ... do whatever you wish when no records found ... Else ... do whatever with found set ... End If I didn't want him to waste his time hunting for the ole Status() functions. Lord am I glad they are gone! Get() is more accurate, appropriate, and easier to write.
MoonShadow Posted March 10, 2005 Posted March 10, 2005 Agreed Steve. Since Heathbo is using vs. 7, it would be: If [ not Get(FoundCount) ] ... which is same as If [ Get(FoundCount) = 0 ] ... ... do whatever you wish when no records found ... Else ... do whatever with found set ... End If I didn't want him to waste his time hunting for the ole Status() functions. Lord am I glad they are gone! Get() is more accurate, appropriate, and easier to write.
MoonShadow Posted March 10, 2005 Posted March 10, 2005 Agreed Steve. Since Heathbo is using vs. 7, it would be: If [ not Get(FoundCount) ] ... which is same as If [ Get(FoundCount) = 0 ] ... ... do whatever you wish when no records found ... Else ... do whatever with found set ... End If I didn't want him to waste his time hunting for the ole Status() functions. Lord am I glad they are gone! Get() is more accurate, appropriate, and easier to write.
Ender Posted March 10, 2005 Posted March 10, 2005 FYI: In FM7, when no records are found, it goes back to the previous found set. So Get(FoundCount) would not work. Better to use Get(LastError)=401. But I'm not sure Heathbo's algorithm is the best. I'd probably try something that uses a relationship between the two databases to search for those records in database 1 that have no matching records in database 2, then import the whole lot at once. For incrementing the existing records, do a similar find in database 1 for those records that do have a matching record in database 2, loop through them once, incrementing the counter in the related record in database 2.
Ender Posted March 10, 2005 Posted March 10, 2005 FYI: In FM7, when no records are found, it goes back to the previous found set. So Get(FoundCount) would not work. Better to use Get(LastError)=401. But I'm not sure Heathbo's algorithm is the best. I'd probably try something that uses a relationship between the two databases to search for those records in database 1 that have no matching records in database 2, then import the whole lot at once. For incrementing the existing records, do a similar find in database 1 for those records that do have a matching record in database 2, loop through them once, incrementing the counter in the related record in database 2.
Ender Posted March 10, 2005 Posted March 10, 2005 FYI: In FM7, when no records are found, it goes back to the previous found set. So Get(FoundCount) would not work. Better to use Get(LastError)=401. But I'm not sure Heathbo's algorithm is the best. I'd probably try something that uses a relationship between the two databases to search for those records in database 1 that have no matching records in database 2, then import the whole lot at once. For incrementing the existing records, do a similar find in database 1 for those records that do have a matching record in database 2, loop through them once, incrementing the counter in the related record in database 2.
Recommended Posts
This topic is 7199 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now