Perl DBI and Show command resultsets


Perl DBI and Show command resultsets


I am trying to run a Show command following a SQL statements. In SQL Asstant it runs fine, getting me multiple of resultsets.  However in Perl it only returns the first part of the result in this case only first DDL.  I am using the ODBC with perl and I use, fetchrow_array().  I have also tried selectall_arrayref(q)

but no luck getting the complete resultsets. It seems somehow I am getting just one row or part of the first array list.

I tried loop through the resultsets as below:

 foreach $row (@$rows) {
      print join(", ", map {defined $_ ? $_ : "(null)"} @$row), "\n";


Also secondly I noticed with no column name it is difficult to force the recordset to spill the specific row. I am not sure what is the column name or names it retuns from a show command with sql via odbc.

Can someone point me to the right direction/s?

Thanks in advance.


Tags (2)
Teradata Employee

Re: Perl DBI and Show command resultsets

When a request can return multiple result sets, you will need an outer loop that checks "state" or "err" to determine if there are more results remaining to process.


Since there is only one column, you probably don't need the column name (though you should be able to obtain it from the metadata, e.g. NAME attribute). Depending on which "fetch" method you choose, try either "shift" (for a list) or accessing the [0] element (for an array).