[From nobody Wed Mar 18 22:50:10 2009 X-Mozilla-Keys: Message-ID: <49BFE752.8090206@berkeley.edu> Date: Tue, 17 Mar 2009 11:09:22 -0700 From: ken uhl <kenuhl@berkeley.edu> User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: beginners@perl.org Subject: class DBI postgres date time format Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit How do I set up table class method to correctly format and write 'updated' column date and time stamp to postgres? I have table entry object that contains this - to inflate and deflate : I think I need to add "has_timestamp" ..... 22 __PACKAGE__->table('dhcpmac'); 23 __PACKAGE__->columns( Primary => qw/rowid/ ); 24 __PACKAGE__->columns( All => qw/rowid mac calnetuid updated updatedby dynhostname ishmael disable/ ); 25 26 __PACKAGE__->has_a( updated => 'DateTime', 27 inflate => sub { DateTime::Format::Pg->parse_timestamptz(shift); }, 28 deflate => sub { DateTime::Format::Pg->format_timestamptz(shift); } ); ... my CGI does this : ... # retrieve old row data 301 my $delta_row = IST::DNSDB::dhcpmac->retrieve($old_rowid) ; 302 my $old_mac = $delta_row->mac(); ... # replace some of the data - including 'updated' 305 $delta_row->mac($new_validated_mac); 306 $delta_row->updated( "now()" ); .. 308 $delta_row->updatedby($calnetuid); ... 313 $delta_row->update(); 314 $delta_row->commit(); ( line 306 crashes with invalid SQL command line value, obviously, but what goes here? ) ? TIA, Ken Uhl, UC Berkeley ]