Link to home
Start Free TrialLog in
Avatar of eteran
eteranFlag for United States of America

asked on

SQL LOOP

I have this code in which I got help in by other experts in the system. This  code gose to a txt file which I download everyday and for now only prints what is in the text file. What I want to accomplish is a delete all record of the table and then begin by uploading the new records one by one. Is there a way to do this. How do I structure the sql with the loop every record is split by "miamimls". Can someone please help.


<%
      Const ForReading = 1
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objTextFile = objFSO.OpenTextFile("c:\sefl_data.txt", ForReading)
     
      Do Until objTextFile.AtEndOfStream
            strNextLine = objTextFile.Readline
            arrServiceList = Split(strNextLine , ",")
           ' Response.Write "Server name:" & arrServiceList(0)

            For i = 1 to Ubound(arrServiceList)
                  Response.write " " & arrServiceList(i)
            response.flush
            Next
      Loop
%>
"miamimls","FL","M1172181","1025193","Clarte Int'l Properties LLC","3055322226","1274527","Penuela,Pablo","","","","","","M","CONDO","FULL SERVICE 5 STAR HOTEL. UNIT WITH OCEAN VIEW. FULLY FURNISHED BY DESIGNER, TOP OF THE LINE APPLIANCES, LUXURIOUS LOBBY, PRIVATE BEACH WITH CABANAS","A","379900","","FL","18683","COLLINS AV","","","2309","-80.12060909860296","25.94903129272457","SUNNYISL","000016","33160","","22","DADE","12025","M Resort Le Meridien","M Resort Le Meridien","2005","","","0","","750","1","1","1","0","","","","","","","","","","","","823","","M RESORT RESIDENCES CONDOUNIT 2309 INDIV 0.338131% INT IN COMMON ELEMENTS OFF","31-22-02-045-2309","4150","2006","2","","22","","","","09/12/2007","","","","","","","","","","","","","","","D09,E05,J02,J04,M01,M05,M17,N10,N11,N13,N19,Q08,T01,T28,U01,U16,W28,X07,X09,X12,Y07","CIPL01","3127720","","0","",""
---------- NEW RECORDS---------------------------------------------------------------------
"miamimls","FL","M1172187","1024855","Astor International Realty","3054876265","2120357","Vargas,Limaris","","","","","","M","CONDO","O","A","324900","","FL","6001","70 ST","","NW","439","-80.29101221387516","25.706129817534272","SMIAMI","Y22922","33143","","40","DADE","12025","","VALENCIA SOUTH MIAMI","2004","","","1010","","1010","2","2","2","0","","","","","","","","","","","","428","","TOWNSITE","","0","2006","25","","40","","","","09/12/2007","","","","","","","","","","","","","","","C02,C05,C13,C23,D09,E05,J02,J07,M01,M05,M17,N02,N10,N11,N19,O14,O17,Q01,T02,T11,T12,T28,U01,W28","AITR01","3160259","","0","",""
ASKER CERTIFIED SOLUTION
Avatar of yourbudweiser
yourbudweiser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eteran

ASKER

Just this would delete all the records in that table.

objConn.Execute "Delete From Table Where...."
Avatar of yourbudweiser
yourbudweiser

didn't you want to delete all records in that table?

your questions stated:

"What I want to accomplish is a delete all record of the table..."
Avatar of eteran

ASKER

yeah, so that sql you worte dose that. I don't have to fo somehting like this

objConn.Execute "Delete * From Table Where MLSCONTAINER"
Have you been able to test the code?
Avatar of eteran

ASKER

no canget get it to mix wityh my code i postedl. can you please help.
Avatar of eteran

ASKER

now the problem is that I only need to insert 3 colums of the data. The 3rd, 89th, 90th colum of the array in the data base to the three fields in my database posted below. How do I go about doing this.
<%
      Const ForReading = 1
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objTextFile = objFSO.OpenTextFile("c:\sefl_data.txt", ForReading)
     
      objConn.Execute "Delete From Table MLS_Picture_Control"
     
      Do Until objTextFile.AtEndOfStream
            strNextLine = objTextFile.Readline
            arrServiceList = Split(strNextLine , ",")
           ' Response.Write "Server name:" & arrServiceList(0)
           
      For i = 1 to Ubound(arrServiceList)
        Response.write " " & arrServiceList(i)
        strSQL = "INSERT INTO MLS_Picture_Control MLS_LISTING_ID, PHOTO_QUANTITY, PHOTO_URL ('" &arrServiceList(i)& "')"
        objConn.Execute strSQL
        response.flush
      Next

objConn.Close
set objConn = nothing          
%>
     For i = 1 to Ubound(arrServiceList)
        Response.write " " & arrServiceList(i)
          If i = 3 or i = 89 or i = 90 Then

strSQL = "INSERT INTO MLS_Picture_Control MLS_LISTING_ID, PHOTO_QUANTITY, PHOTO_URL ('" &arrServiceList(i)& "')"
        objConn.Execute strSQL
        response.flush

        End If
      Next