How can I get the temp table SQL field names using Perl?

Below is the code that I use to run the query, parse the result set and parse the strings (respectively)

$exec_ret = $DBS->SQLExecSQL($STMT);

while ($DBS->SQLFetch() == *PLibdata::RET_OK)
{
      $rowfetch = $DBS->{Row}->GetCharValue($colname[$i]);
}

Can I get the column / field name of the temp table using similar syntax? $colname[$i]predefined at the top to hold column / field names. This is hardcoded right now, but I would rather automate it by pushing the values ​​in $colnameinside a loop that runs before the lines are parsed.

+3
source share
2 answers

What module do you use to access the database? I do not know the names of the methods.

DBI, :

my $sth = $dbh->prepare($STMT);
$sth->execute;
my $columns = $sth->{NAME_uc};

while (my $row = $sth->fetch) {
  for my $i (0 .. $#$row) {
    print "$columns->[$i]: $row->[$i]\n";
  }
  print "\n";
}

3 : NAME , , NAME_lc , NAME_uc . , NAME .

+6

SHOW TABLE yourtable , SELECT.

0

Source: https://habr.com/ru/post/1705981/


All Articles