New API interface suggested for Perl DBI call.

    The latest Perl DBI support array operation, use an array as a bind value when operating with database. From the database layer, it's not a new feature, like Oracle Pro*C & OCI interface. After use of the array interface of Perl, I have suggestion to add a new API interface to Perl DBI. Usually the Perl DBI will return the result based on row as following:

{
  ROW1  {col1, col2, col3, col4},
  ROW2  {col1, col2, col3, col4},
  .....
  ROWn  {col1, col2, col3, col4}
}

    But when binding, we need to bind a column based array :

$sth->bind_param_array( COL1={row1, row2, ... rown});
$sth->bind_param_array( COL2={row1, row2, ... rown});
.....
$sth->bind_param_array( COLn={row1, row2, ... rown});

    So we need do convertion in program, from the database interface layer, when using array fetch, the return result is actually column based, as following :

COL1={ROW1, ROW2, ..., ROWn}
COL2={ROW1, ROW2, ..., ROWn}
......
COLn={ROW1, ROW2, ..., ROWn}

    Perl do the column-row conversion for us, and we do the row-column conversion for array binding. Why not introduce an interface to return column based array in DBI for performance improve?

Comments (2)

What you're looking for is already supported by DBI.
Take a look at the execute_for_fetch() method.

I think you misunderstand me, I want the selectall_xxx and fetchall_xxx call to return column arrays, not row arrays.

Post a comment

SCode:
Mail(*, but will not be displayed):
Home: