List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:November 17 2009 3:50pm
Subject:Re: Query!
View as plain text  
Gaurav,

 >How can I detect from my code whether a table has been updated in the 
Database manually

Have a look at "Transaction Time Validity" in 
http://www.osdbzine.net/issue6.pdf and http://www.osdbzine.net/issue7.pdf.

PB

-----

Michael Dykman wrote:
> I'm sorry, you are way off here in what this actually does.
>
> mysql_affected_rows is only going to tell you how many rows were
> affected by the execution of the last statement made on your current
> connection.  It is not an interface to a magic genie maintaining watch
> over the state of your entire database.
>
> The only ways you might accomplish anything even remotely like what
> you have in mind are:
>          have your watcher thread thread make a snapshot of the entire
> db and run a diff on every cycle which would be ridiculously expensive
> in terms of execution time not to mention locking up database access
> pretty good.
>
> OR
>         have the external updating process record a log of changes to
> a  particular table, then you monitor thread can scan that table for
> new entries.
>
>
>  - michael dykman
>
> On Tue, Nov 17, 2009 at 7:06 AM, Gaurav Nigam (TMP-Japan)
> <G.Nigam@stripped> wrote:
>   
>> Can somebody please help!
>>
>> There are two queries -
>> 1. How can I detect from my code whether a table has been updated in the Database
> manually (I am firing delete from testtable where SrNo>=9; on the Database server) and
> not from the code itself. I am running this code -
>>
>> conn = mysql_init(NULL);
>>
>>            /* Connect to database */
>>            if (!mysql_real_connect(conn, server, user, password, database, 0,
> NULL, 0)) {
>>              fprintf(stderr, "%s\n", mysql_error(conn));
>>              exit(1);
>>            }
>>
>>            my_ulonglong affect_fields;
>>            while(1)
>>            {
>>                        affect_fields = mysql_affected_rows(conn);
>>                        if ((long) affect_fields >=1)
>>                        {
>>                                    printf("%ld products updated\n\n",  (long)
> affect_fields);
>>                        }
>>            }
>>
>> 2. And if the table is really updated/inserted/deleted for any record then how to
> check which that record was.
>>
>> Regards,
>> Gaurav.
>>
>>     
>
>
>
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.425 / Virus Database: 270.14.67/2506 - Release Date: 11/16/09 07:43:00
>
>   

Thread
Query!TMP-Japan)17 Nov
  • Re: Query!Michael Dykman17 Nov
    • Re: Query!Peter Brawley17 Nov