Re: DBI insert vs update question

2005-07-10 Thread Wiggins d'Anconia
Peter Rabbitson wrote: > Hello everyone, > I want someone to share his expertise on the following: > Suppose we have a table with some data that periodically must be synced > with an external source, which provides only partial information (e.g. > it might provide all the fields for a new record,

Re: DBI insert vs update question

2005-07-10 Thread David Van Ginneken
Below is taken from: http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm Also look at: http://dev.mysql.com/tech-resources/articles/4.1/prepared-statements.html Prepared statement support (server side prepare) To use server side prepared statements, all you need to do is set the variabl

Re: DBI insert vs update question

2005-07-10 Thread Mads N. Vestergaard
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey Peter, Are you sure about that? As far as I understand, what you say you can't do, is to have two prepares for example: my $dbh = DBI->connect("dbi:mysql:database","user","pass"); my $foo = $dbh->prepare("SELECT * FROM ."); my $bar = $dbh->

Re: DBI insert vs update question

2005-07-10 Thread Peter Rabbitson
> I'm sure others will give you more informed answers.. But why can't > you create multiple statement handlers under the same connection? > Because you can't. One connection holds only one prepared statement (at least in MySQL). If you prepare $statement2 on the same $dbh, $statement1 automati

Re: DBI insert vs update question

2005-07-10 Thread Peter Rabbitson
On Sun, Jul 10, 2005 at 06:23:19PM +0300, Octavian Rasnita wrote: > Can't you use the replace sql query? > > Use it like you use "insert". It will insert new rows where there are no > rows, and do an update where there are rows... > Negative. REPLACE is just a shortcut for DELETE FROM... INESERT

Re: DBI insert vs update question

2005-07-10 Thread Octavian Rasnita
10, 2005 18:09 PM Subject: DBI insert vs update question > Hello everyone, > I want someone to share his expertise on the following: > Suppose we have a table with some data that periodically must be synced > with an external source, which provides only partial information (e.g. > it

DBI insert vs update question

2005-07-10 Thread Peter Rabbitson
Hello everyone, I want someone to share his expertise on the following: Suppose we have a table with some data that periodically must be synced with an external source, which provides only partial information (e.g. it might provide all the fields for a new record, but might provide only a single