Skip to main content
Inspiring
May 28, 2008
Question

Update recordset after cfmail?

  • May 28, 2008
  • 1 reply
  • 388 views
I would like to update a status field for each record that is used in cfmail tag after the email is sent. My thought is that I can could use a cfquery like so:
SELECT email, firstname, id, sendstatus
FROM emailtable
WHERE sendstatus = 0
ORDER BY ID DESC LIMIT 5000

I would then use this recordset inside my cfmail tag but once the send is complete I would like to update the sendstatus field from a zero to a 1. When the page is called again these records would be skipped and the next 5000 records would be sent.

I assume that I could use a cfloop to loop through the original query and do a UPDATE for each record but that does not seem to be very efficient. Is there a better way that I could use so that I would only execute one update statement to update all of the records without repeating the original sql statement?
    This topic has been closed for replies.

    1 reply

    Inspiring
    May 28, 2008
    you don't need a loop. You need to learn a new keyword in sql "IN". To reference the first query, use the coldfusion function valuelist.
    Inspiring
    May 29, 2008
    quote:

    Originally posted by: Dan Bracuk
    you don't need a loop. You need to learn a new keyword in sql "IN". To reference the first query, use the coldfusion function valuelist.

    Thanks Dan! I will look into this and see what I can do.