Agum
New Member
Hi,
Perl question.
If I want to execute a SELECT query to a SQL database and get its results and basically just print the results out line by line, what is the exact syntax to do it?
From Googling, I basically know so much:
if there is anything wrong, please correct me.
I mostly need help at what I need to put inside the while loop.
all I need to do is print out the results one by one.
examples online told me to use bind_columns.
I can't really use it because my table has way too many columns and even just picking those that I need, there are way over 20+ of them.
please don't ask me to use PHP, I need to do this in Perl for a reason...
Thanks a lot in advance!
Perl question.
If I want to execute a SELECT query to a SQL database and get its results and basically just print the results out line by line, what is the exact syntax to do it?
From Googling, I basically know so much:
Code:
$sql = "SELECT * FROM table1";
$dbh = DBI->connect( 'DBI:Oracle:instance', 'user', 'pass') or die "dead: ".DBI->errstr;
$sth = $dbh->prepare($sql);
$sth->execute();
while ($sth->fetch())
{
# i need help here
}
$sth->finish();
$dbh->disconnect;
if there is anything wrong, please correct me.
I mostly need help at what I need to put inside the while loop.
all I need to do is print out the results one by one.
examples online told me to use bind_columns.
I can't really use it because my table has way too many columns and even just picking those that I need, there are way over 20+ of them.
please don't ask me to use PHP, I need to do this in Perl for a reason...
Thanks a lot in advance!