In article <[EMAIL PROTECTED]>,
Stephen Rasku <[EMAIL PROTECTED]> writes:

> I am using the C API with MySQL 4.0.17 on QNX 6.2.1b.
> I want to update the rows that are returned as I get them.  Is this
> possible.  Here's a simplified version of what I am trying to do:

> query = "select seqNo, priority from packet where timestamp < now() -
> interval 15 second order by priority desc, timestamp";
> mysql_query(&mysql, query);
> result = mysql_use_result(&mysql);

> while (row = mysql_fetch_row(result))
> {
>     seqNo = atoi(row[0]);
>     priority = atoi(row[1]);

>     sprintf(updateStr, "update packet set timestamp = now() where
> seqNo = %d", seqNo);
>     mysql_query(&mysql, updateStr);
> }

I guess this is an oversimplification.  Often you can use a single SQL set
operation instead of a loop.  Your example would probably be the same as

  UPDATE packet
  SET timestamp = now()
  WHERE timestamp < now() - INTERVAL 15 SECOND

Maybe you should explain what you're trying to achieve, not what you
think how to do it.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to