Key Key
May I suggest you use your created file name as the name of the table to select into, browse THAT and, if saisfied, commit it, to a similarly created filespec. E.g. Dim lcLECNAME, lcOCName, lcFILEPATH as string, iCOUNT as integer Fetch first from PHONE_COMPANY For iCount = 1 to 7 lcLECNAME = PHONE_COMPANY.NAME Select * from EXCHANGES where EXCHANGES.OCNAME = lcLECNAME into lcOCName Browse * from lcOCName lcFILEPATH = "C:\temp\" + lcOCName Commit table lcOCName as lcFilePath Fetch next from PHONE_COMPANY Next Besides, if you check your code, your fetch next was getting the next record from the table you'd just selected - NOT the orig. PHONE_COMPANY. HTH Terry McDonnell -----Original Message----- From: Lawson Key [mailto:[EMAIL PROTECTED] Sent: 11 August 2005 02:00 To: Terry McDonnell Subject: MI-L Query in a loop - naming the selection? Hi listers! Have a MapBasic question about a select statement within a Do...Loop. >From a table containing all US telephone exchanges (EXCHANGES), need to select the exchanges belonging to several companies, and need to save them as individual tables for each company. To accomplish this, I've set up a Do...Loop with the appropriate query inside it, and a table with a single column containing the names of the companies I'm interested in looking at (PHONE_COMPANY). The idea is to fetch the first company from the PHONE_COMAPNY table, select the exchanges for that company from EXCHANGES, and name & save the resulting table (based on the name of the company in PHONE_COMPANY)....repeat process for each company in the PHONE_COMPANY TABLE. My problem is naming & saving the tables in the loop. I have a sample of my code below, which works okay, but I can't figure out how to name the results tables. I can't use a variable in the "into" clause of the select statement. I've tried to work around this with the Run Command statement, but haven't been able to make it work. I want the name of the resulting table to be the same as the company name from PHONE_COMPANY. Help! My code below is what I have been able to work out so far, but this just creates temporary tables with default names, doesn't name or save them. -----Lawson Dim LECNAME as string, COUNT as integer COUNT = 1 Fetch first from PHONE_COMPANY Do LECNAME=PHONE_COMPANY.NAME Select * from EXCHANGES where EXCHANGES.OCNAME=LECNAME into selection Browse * from selection Fetch next from LECNAMES COUNT = COUNT + 1 Loop until COUNT = 7 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 17485
