We help IT Professionals succeed at work.

SQL LOOP

eteran
eteran asked
on
1,074 Views
Last Modified: 2012-05-05
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","",""
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Just this would delete all the records in that table.

objConn.Execute "Delete From Table Where...."
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..."

Author

Commented:
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?

Author

Commented:
no canget get it to mix wityh my code i postedl. can you please help.

Author

Commented:
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.