<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>It looks like your "updated" column is mapped as a DateTime object (line 26).</div><div><br></div><div>You probably want to do something like this:</div><div><br></div><div><font class="Apple-style-span" face="Courier"><font class="Apple-style-span" color="#FF0000">$delta_row-&gt;updated( DateTime-&gt;now() );</font></font></div><div><br></div><div>Further resources:</div><div><br></div><div><a href="http://search.cpan.org/dist/DateTime/lib/DateTime.pm">http://search.cpan.org/dist/DateTime/lib/DateTime.pm</a></div><div><br></div><div><a href="http://search.cpan.org/dist/DateTime-Format-Pg/lib/DateTime/Format/Pg.pm">http://search.cpan.org/dist/DateTime-Format-Pg/lib/DateTime/Format/Pg.pm</a></div><div><br></div><div>cheers</div><div><br></div><div>-- frosty</div><div><br><div><div>On Mar 18, 2009, at 4:01 PM, ken uhl wrote:</div><br><blockquote type="cite"><br><br><div>From: ken uhl &lt;<a href="mailto:kenuhl@berkeley.edu">kenuhl@berkeley.edu</a>&gt;<br></div><div>Date: March 17, 2009 11:09:22 AM PDT<br></div><div>To: <a href="mailto:beginners@perl.org">beginners@perl.org</a><br></div><div>Subject: class DBI postgres date time format<br></div><br><br>How do I set up table class method to correctly format and write 'updated' &nbsp;column &nbsp;date and time stamp to postgres?<br><br>I have table entry object that contains this - to inflate and deflate :<br><br>I think I need to add &nbsp;"has_timestamp" <br>.....<br><br> &nbsp;&nbsp;&nbsp;22 __PACKAGE__-&gt;table('dhcpmac');<br> &nbsp;&nbsp;&nbsp;23 __PACKAGE__-&gt;columns( Primary =&gt; qw/rowid/ );<br> &nbsp;&nbsp;&nbsp;24 __PACKAGE__-&gt;columns( All =&gt; qw/rowid mac calnetuid updated updatedby dynhostname ishmael disable/ );<br> &nbsp;&nbsp;&nbsp;25<br> &nbsp;&nbsp;&nbsp;26 __PACKAGE__-&gt;has_a( updated =&gt; 'DateTime',<br> &nbsp;&nbsp;&nbsp;27 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inflate =&gt; sub { DateTime::Format::Pg-&gt;parse_timestamptz(shift); },<br> &nbsp;&nbsp;&nbsp;28 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deflate =&gt; sub { DateTime::Format::Pg-&gt;format_timestamptz(shift); } );<br><br>...<br><br>my CGI &nbsp;does this :<br><br>...<br># &nbsp;retrieve old row data &nbsp;&nbsp;&nbsp;301 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $delta_row = IST::DNSDB::dhcpmac-&gt;retrieve($old_rowid) ;<br> &nbsp;&nbsp;302 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $old_mac = $delta_row-&gt;mac();<br>...<br># &nbsp;replace some of the data - including 'updated'<br> &nbsp;&nbsp;305 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$delta_row-&gt;mac($new_validated_mac);<br> &nbsp;&nbsp;306 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$delta_row-&gt;updated( "now()" );<br>..<br> &nbsp;&nbsp;308 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$delta_row-&gt;updatedby($calnetuid);<br>...<br> &nbsp;&nbsp;313 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$delta_row-&gt;update();<br> &nbsp;&nbsp;314 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$delta_row-&gt;commit();<br><br>( line 306 crashes with invalid SQL command line value, obviously, but what goes here? )<br><br>?<br><br>TIA,<br>Ken Uhl,<br>UC Berkeley<br><br><br><br><br>_______________________________________________<br>SanFrancisco-pm mailing list<br><a href="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</a><br>http://mail.pm.org/mailman/listinfo/sanfrancisco-pm<br></blockquote></div><br></div></body></html>