in reply to Flexible Update SQL
You can do whatever you want by hand of course but this stuff gets hairy quickly and I would strongly recommend taking the learning curve hit up front for DBIx::Class or something similar. If you want a bit more more raw try SQL::Abstract.
use SQL::Abstract; my $sql = SQL::Abstract->new; my %data = ( name => 'test_name', phone => 'test_phone', city => 'test_city', country => 'test_country' ); my ( $statement, @bind ) = $sql->update("phone", \%data); printf("SQL --> %s\n %s\n\n", $statement, join(",", @bind) ); delete @data{qw( phone city )}; ( $statement, @bind ) = $sql->update("phone", \%data); printf("SQL --> %s\n %s\n\n", $statement, join(",", @bind) ); __END__ SQL --> UPDATE phone SET city = ?, country = ?, name = ?, phone = ? test_city,test_country,test_name,test_phone SQL --> UPDATE phone SET country = ?, name = ? test_country,test_name
|
---|