Automatically updating Timestamp Column with DBD:MYSQL

Automatically updating Timestamp Column with DBD:MYSQL

am 14.04.2005 01:00:34 von zzapper

Hi,
It's late (at least here in my part of the universe) but I'm inserting records into a mysql database
with Perl DBI DBD:MySQL and was expecting my first & only timestamp field to be updated without me
needing to specifically mention it in the insert clause, but the field is obstinately remaining null

Any Ideas?



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Automatically updating Timestamp Column with DBD:MYSQL

am 14.04.2005 01:51:03 von MTA-Traffic

are your updates actually working?

this works ...

test> create table x1 (
-> t timestamp(14),
-> val varchar(16) );
Query OK, 0 rows affected (0.19 sec)

test> select * from x1;
Empty set (0.03 sec)

test> insert into x1 values(now(), 'hcir');
Query OK, 1 row affected (0.11 sec)

test> select * from x1;
+---------------------+------+
| t | val |
+---------------------+------+
| 2005-04-13 15:49:05 | hcir |
+---------------------+------+
1 row in set (0.00 sec)

test> update x1 set val='rich' where val='hcir';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0

test> select * from x1;
+---------------------+------+
| t | val |
+---------------------+------+
| 2005-04-13 15:49:25 | rich |
+---------------------+------+
1 row in set (0.00 sec)

test>

On Apr 13, 2005, at 3:00 PM, zzapper wrote:

> Hi,
> It's late (at least here in my part of the universe) but I'm inserting
> records into a mysql database
> with Perl DBI DBD:MySQL and was expecting my first & only timestamp
> field to be updated without me
> needing to specifically mention it in the insert clause, but the field
> is obstinately remaining null
>
> Any Ideas?
>
>
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=traf@mtaonline.net
>
>

- hcir


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Automatically updating Timestamp Column with DBD:MYSQL

am 14.04.2005 01:57:32 von Paul DuBois

At 0:00 +0100 4/14/05, zzapper wrote:
>Hi,
>It's late (at least here in my part of the universe) but I'm
>inserting records into a mysql database
>with Perl DBI DBD:MySQL and was expecting my first & only timestamp
>field to be updated without me
>needing to specifically mention it in the insert clause, but the
>field is obstinately remaining null
>
>Any Ideas?

Let's see the table definition. In recent versions of MySQL,
you can declare a TIMESTAMP such that it _can_ store NULL values,
and such that it doesn't automatically update.

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Automatically updating Timestamp Column with DBD:MYSQL

am 14.04.2005 10:56:21 von zzapper

On Wed, 13 Apr 2005 18:57:32 -0500, wrote:

>At 0:00 +0100 4/14/05, zzapper wrote:
>>Hi,
>>It's late (at least here in my part of the universe) but I'm
>>inserting records into a mysql database
>>with Perl DBI DBD:MySQL and was expecting my first & only timestamp
>>field to be updated without me
>>needing to specifically mention it in the insert clause, but the
>>field is obstinately remaining null
>>
>>Any Ideas?
>
>Let's see the table definition. In recent versions of MySQL,
>you can declare a TIMESTAMP such that it _can_ store NULL values,
>and such that it doesn't automatically update.
>
>--
Paul
I'd just declared it as a timestamp from my gui sqlyog

Following your advice I then went back in and altered the field to Timestamp not Null

Nothing appeared to change from my perl script

From within my GUI I wrote an insert statement, which correctly inserted a timestamp.

I went back to my perl script and suddenly that was working:-
(Also all the Old records had a completed timestamp (today))

So I guess your

>In recent versions of MySQL,
>you can declare a TIMESTAMP such that it _can_ store NULL values,
>and such that it doesn't automatically update.

Is the solution " a nice little trap for the unwary"

THNX





--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org