I wrote a short script to pull the data from a field ("Director") in Links to populate a new table called People. Only it is not pulling the field Director. I am not sure what the correct syntax is. Can you take a look and see what is wrong?
#!/usr/bin/perl
# ==================================================================
# Links SQL - enhanced directory management system
###### Sends all Directors names to db People
use strict;
use lib '/hd2/web/b/bcdb/public_html/bcdb/admin';
use Links qw/$IN $DB $CFG $USER/;
Links::init ('/hd2/web/b/bcdb/public_html/bcdb/admin');
Links::init_user();
local $SIG{__DIE__} = \&Links::fatal;
update_people();
sub update_people {
# --------------------------------------------------------
my $link_db = $DB->table('Links');
my $catlink_db = $DB->table('People');
my $sth = $link_db->select ( ['ID'] );
while ( my ($id) = $sth->fetchrow_array ) {
my $desc = $sth->{'Director'};
$catlink_db->add ( { Name => $desc }, { Job => "Director" } );
}
print $IN->header();
print "Done Updating People!\n\n";
}
1;
FWIW, yes, I know I can just copy this across.... I need to manipulate the data before writting it to People, which is why I want to run a script. I have just left that part out until I get it writing correctly!
Thanks!
Dave
dave
Big Cartoon DataBase
Big Comic Book DataBase
#!/usr/bin/perl
# ==================================================================
# Links SQL - enhanced directory management system
###### Sends all Directors names to db People
use strict;
use lib '/hd2/web/b/bcdb/public_html/bcdb/admin';
use Links qw/$IN $DB $CFG $USER/;
Links::init ('/hd2/web/b/bcdb/public_html/bcdb/admin');
Links::init_user();
local $SIG{__DIE__} = \&Links::fatal;
update_people();
sub update_people {
# --------------------------------------------------------
my $link_db = $DB->table('Links');
my $catlink_db = $DB->table('People');
my $sth = $link_db->select ( ['ID'] );
while ( my ($id) = $sth->fetchrow_array ) {
my $desc = $sth->{'Director'};
$catlink_db->add ( { Name => $desc }, { Job => "Director" } );
}
print $IN->header();
print "Done Updating People!\n\n";
}
1;
FWIW, yes, I know I can just copy this across.... I need to manipulate the data before writting it to People, which is why I want to run a script. I have just left that part out until I get it writing correctly!
Thanks!
Dave
dave
Big Cartoon DataBase
Big Comic Book DataBase