Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Posts
    66

    Unanswered: stored procedure help

    can someone help me convert the following asp to a stored procedure

    i need to loop through a query and do the followoing:

    select * from s where geographic=""
    do while not rs.eof
    if left(destination,1)="0" then
    if cint(mid(destination,2,1))>1 then
    destination="0044" & mid(destination,2,ldestination-1)
    end if
    end if
    sqldc="select top 1 code from dialcodes where '" & destination & "' like code + '%' ORDER BY len(code) desc"
    openrssql rsdc,sqldc
    if not rsdc.eof then
    'do while not rsdc.eof
    response.write rsdc("code") & "(" & rsdc("geographic") & ")"
    'rsdc.movenext
    'loop
    sqlu="update statstest set geographic='" & rsdc("geographic") & "' where ddi='" & rs("ddi") & "'"
    savesql=savesql & sqlu
    'response.write sqlu
    else
    sqlu="update statstest set geographic='unknown' where ddi='" & rs("ddi") & "'"
    end if
    rs.movenext
    loop

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Have you given it a try yourself yet? Post the code that you have come up with so far.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jun 2006
    Posts
    66
    i have the whole middle

    just how do I loop through a recordset and then say executing a stored procedure that does the rest

    i need to know how to do the
    do while not rs.eof
    exec mysp
    rs.movenext
    loop

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You don't loop through the recordset. You process the entire set at once. That is the beauty of set-based SQL.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Jun 2006
    Posts
    66
    but i need to loop through and only do for those where geographic is null

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •