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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.