Hi you almost got it is very simple but since english is my second or third language is getting hard, look you almost got it, I want to do this, from a MYSQL table call PATENTES get ONLY the field PAT, to do this I have to do this :
my $dbh = DBI->connect("DBI:mysql:database=proyecto;host=localhost",
"root", "xyz123",
{'RaiseError' => 1});
my $sth = $dbh->prepare("SELECT PAT FROM patentes");
$sth->execute();
while ((my @row) = $sth->fetchrow_array()) {
print "@row->[0]\n";
}
so far so good, at this point I have @row->[0] that has all the data from the field PAT of the table PATENTES.
Now with these array I want to use it in another file this is a CSV datafile and it has a PAT field too, so I want to extract the data from this file using PAT and if posible to create a new CSV file with the name of the field PAT using INTO OUTFILE, I try to do this but did not work:
my $dbh = DBI->connect("DBI:mysql:database=proyecto;host=localhost",
"root", "xyz123",
{'RaiseError' => 1});
my $sth = $dbh->prepare("SELECT PAT FROM patentes");
$sth->execute();
while ((my @row) = $sth->fetchrow_array()) {
my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');
$dbh->func( 'cars', 'CSV', 'testperl.csv', 'ad_catalog');
my $sth = $dbh->prepare("SELECT * INTO OUTFILE @row->[0].csv FROM ca
+rs WHERE pat = @row->[0]);
$sth->execute();
}
Hope this is more exact |