I have a situation where my code would read data from Sybase tables and display it via HTML using SYBPerl ...
now the data is moving to DB2 so i want to do the same thing with DBI DB2 code.
so ... My understanding of what existing code is doing is it is building an Array of assoc arrays to pass back for processing by the rest of the script.
FOcus on the while loop... the doc says the dbnextrow(1) returns a hash of column/value pairs....
so im looking for the equal in DBI DB2 speak.... Thanks !!
Expand|Select|Wrap|Line Numbers
- sub get_isr2_rqsts() {
- ( $dbh, $id_rqst, $orderby ) = @_;
- # Create the SQL statement
- $sql = "SELECT a.*, b.desc_cd, b.cd_cd_val, b.cd_pcklst_type FROM isr2_aud_log a, pcklst b ";
- $sql .= "WHERE id_secr_rqst = $id_rqst";
- $status = $dbh->dbcmd( $sql );
- ### Execute the SQL statement
- if (( $status = $dbh->dbsqlexec ) == &FAIL ) {
- &error_log( $LOG_PATH, "get_rqsts",
- "dbsqlexec failed \n $sql");
- return($status);
- }
- ### Get the results
- if (( $status = $dbh->dbresults ) == &FAIL ) {
- &error_log( $LOG_PATH, "get_rqsts",
- "dbresults failed \n $sql");
- return($status);
- }
- # The following is the only way I could figure out how
- # to store and pass a complex data structure in perl
- ###############################################
- %arr = 0;
- $query_idx=0;
- @rqst_results = null;
- while ( %arr = $dbh->dbnextrow(1) ) {
- %{$rqst_results[$query_idx]} = %arr;
- $query_idx++;
- }
- # Free up the database work space
- $dbh->dbcanquery;
- $dbh->dbfreebuf;
- return @rqst_results;
- }