I am using Perl and MySQL to create a customer catalog. What I would like to do is create a change log, so when I update the primary table I have a record of it.
I have created my tables as such:
CREATE TABLE catalog ( phone_number VARCHAR(10) PRIMARY KEY NOT NULL, name VARCHAR(255), address VARCHAR(255), notes VARCHAR(255) ); CREATE TABLE change_log ( transaction_id INT(10) PRIMARY KEY NOT NULL AUTO INCREMENT, timestamp TIMESTAMP, number_record VARCHAR(255), action VARCHAR(255) );
So I update the DB pragmatically like so:
#!/usr/bin/perl use strict; use warnings; use DBI; use DBD::mysql; #this is my config module use DBase::MySQL::Config qw(DB_CUSTOMER_CATALOG DB_USER DB_PW); my $dbh = DBI->connect(DB_CUSTOMER_CATALOG, DB_USER, DB_PW); my $query = "INSERT INTO catalog (phone_number) VALUES ('5555555555'), + ('1111111111');"; $dbh->do($query); $dbh->disconnect();
What I would like to do is: if a record exists, update the record with name, address, etc. and insert a new record into the change log, with number affected and action performed. If a record doesn't exist, insert the new record into the customer catalog (along with name, address, and any notes where applicable) and add a new record to the change log noting the addition.
Thanks in advance for any assistance. This one has had me stuck.
In reply to Using Perl and MySQL for Activity Log by PyrexKidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |