Howdy, how can I add an extra field to an already created table in sql ? Andrew rich
-----Original Message----- From: Sascha Kettner [mailto:[EMAIL PROTECTED]] Sent: Sunday, 21 April 2002 9:29 PM To: [EMAIL PROTECTED] Subject: Number pickup with parallel updating? with script! Hi! I have a small problem: a habe a database containing three fields number, timestamp, used i allready inserted into the "number" fileds about 50.000 random and unique numbers - timestamp and used are empty With my perl script i have to do the following: look into the database for the first entry with having timestamp and used empty then updating the timestamp field with the actual date. My script then in addtion presents the number to the customer via webinterface. the next time i run the script the same procedure must be repeated, so finding the first empty entry (empty timestamp field) and then updating this filed with a timestamp. How can i realize this with using perl ? Any advice? How to connect to database using perl i allready know but iam trying to find out how manage this small problem the most easy way... Thanks in advance Sascha ---------------------------------------------------------------------- ps: here is the script i�ve done so far, but it is not working! Use DBI(); sub dojob { # Now retrieve data from the table. my $dbh = DBI->connect("DBI:mysql:database=dbname;host=hostname", "user", "pass", {'RaiseError' => 1}); my $sth = $dbh->prepare('select * from smartaktion where activated LIKE "0000000000000" Limit 1); #(schould select 1st entry in db with "activated="null"# $sth->execute(); #do my job# while (my $ref = $sth->fetchrow_hashref()) { }; #try to put the slected entry into an array# $sth->finish(); my $sth = $dbh->prepare('update smartaktion SET activated=NOW() WHERE serial=$ref->{'serial'}'); #(should select the picked serial from above and update the timestamp-field "activated" with actual timestamp)# $sth->execute(); #do my job# $sth->finish(); # Disconnect from the database. $dbh->disconnect(); #done# }; (however, it is not working?!) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
