Hello.


> 1) The record is the actual record in the database not a possible

>duplicate,  e.g. is there a built-in record number identifying the

>actual DB record or do I have to organise that in the table structure.



Perhaps, you should add UNIQUE key to you table structure. See:

  http://dev.mysql.com/doc/refman/5.0/en/create-index.html



> 2) The record hasnt been or cannot be changed by another

>thread/process,  possibly by. locking / re-reading the record (is there

>another way?).



MySQL provides different kinds of locking. See:

  http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html

  http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-model.html







Jan M wrote:

> Hi,

> 

> Newbie question (MySql 5.0 using C API). I've searched the mysql

> website/Internet but cannot find the answer.

> 

> How do I update a record obtained from a query result while ensuring that:

> 

> 1) The record is the actual record in the database not a possible duplicate,

> e.g. is there a built-in record number identifying the actual DB record or

> do I have to organise that in the table structure.

> 

> 2) The record hasnt been or cannot be changed by another thread/process,

> possibly by. locking / re-reading the record (is there another way?).

> 

> How do I lock and re-read the [actual] record anyway?

> 

> Code snippet:

> 

>  sprintf(szStr,

>          "SELECT * FROM %s WHERE UserName = '%s'",

>          DB_TABLE,

>          szUserName);

> 

>  if(mysql_real_query(db, szStr, strlen(szStr)) == 0)

>   {

>    result = mysql_store_result(db);

> 

>    if(result)  // There are rows

>     {

>      while ((row = mysql_fetch_row(result)))

>       {

>        // *** I need to update the record here! ***

>       }

> 

>      mysql_free_result(result);

>     }

> 

> TIA.

> 

> Jan

> 

> 

> 

> 



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com




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

Reply via email to