Results 1 to 4 of 4

Thread: get additional information from resultset

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    I have a stored procedure that returns invoice order numbers that did not seem to get processed.

    from those numbers listed in my result set I then want to query out all those invoice order numbers that were cancelled from another table.

    could someone give some sample code on how to do this?

    so I get a bunch of numbers back from a query and now i want to query on those numbers and make sure none were cancelled???

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    Hi Bebe

    Once You have have the first recordset try the following

    Code:
    StrSQL = "SELECT * FROM Maintable As Mai, SecondTable As sec WHERE (msi.InvoiceNumber = " & recordset(0)
    While Not recordset.EOF
    strSql = strSql & " Or msi.InvoiceNumber = " & recordset(0)
    recordset.MoveNext
    Wend
    
    StrSql = StrSql & ") AND msi.InvoiceNumber = Sec.InvoiceNumber AND sec.Canceled = False"
    recordset.Open ....
    alternatly you can use this code which does it in one recordset

    SELECT .... FROM maintable WHERE ...Your clauses to see if they have been processed... AND invoicenum IN (SELECT invoicenum FROM secondTable WHERE Canceled = False)

    Hope This Helps

    Ian




    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    StrSql = StrSql & ") AND msi.InvoiceNumber = Sec.InvoiceNumber AND sec.Canceled = False"
    recordset.Open ....


    what comes after the open

    and why does there not need to be a join on the two tables for this to work. It is two separate tables that we are getting information on?

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Hi Bebe

    The First Way that I Did it is the nasty hashed way of doing it using two record sets to solve the problem. You get all the Invoices that haven't been processed from your stored procedure then pass the invoice number from that recordset into the WHERE clause of the second recordset to get the ones that haven't been cancelled. Also, there is a join, it is the "AND msi.InvoiceNumber = Sec.InvoiceNumber"

    But I would recommend either ammending your SP or creating a new one to include the nested query that I showed becuase it only uses one record set and Will be a lot quicker to process.

    If you need any more questions awnsered, feel free to reply back

    Hope This Helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

Posting Permissions

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



Click Here to Expand Forum to Full Width