> -Original Message-
> From: Miguel Cardenas [mailto:[EMAIL PROTECTED]
> Sent: Saturday, May 26, 2007 8:21 AM
> To: mysql@lists.mysql.com
> Subject: Avoiding TIMESTAMP
>
> Hello list
>
> I need to solve a little problem but don't mind how, maybe you could
> suggest
> something.
>
> I have a database which registers payments, records have a AUTO_INCREMENT
> field to assign a unique consecutive number associated to every payment,
> some
> other fields that store the amount, type of payment, etc. and another
> TIMESTAMP field that stores the date and time.
>
> One of the fields contains the username for who received the payment and
> it is
> stored automatically by the software, so I can know who processed the
> payment, when, and all related information...
>
> In the first stage of the system it worked only for 'localhost' and a
> unique
> test user, so all my current payments have registered that user. Now the
> system is able to select a host and a user, so I want to update the test
> user
> username for a real user, the database has already some records and would
> not
> like to reenter them by hand logging in as a real user.
>
> My problem is this... if I update the username field, the TIMESTAMP
> updates
> the date and time of the payment to the current values and the payment
> date/time does not coincide then...
Are you inserting null into the timestamp column, either explicitly or
implicitly (like with a trigger)? If I don't specify the timestamp column,
as shown below, it leaves it alone. Using MyISAM on 5.0.24-NT, it works as
you want. Assuming I've inferred your table definition, that is.
drop table if exists payment;
create table payment (
id integer not null AUTO_INCREMENT primary key,
username varchar(255) not null,
amount FIXED(10,2),
txtime timestamp not null
);
insert into payment (username, amount) values ('tjl', 1234567.89);
select * from payment;
-- note time
-- wait a little while
update payment set username='aal';
select * from payment;
-- same time...
update payment set username='tjl', txtime=null;
select * from payment;
-- updated time
Tim
>
> Is there a way to update only that one field avoiding the TIMESTAMP
> update?
> One way is to update both fields, specifying the user and the same
> date/time
> by hand, but comes a new problem, payments have different date and time,
> so I
> would need to create a small routine to update records one by one with its
> particular date/time, but maybe there is another way to do it with a
> single
> command...
>
> Thanks for any comment
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]