473,383 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Perl DBI database connection conversion

hi all ,
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
  1. sub get_isr2_rqsts() {
  2.    ( $dbh, $id_rqst,  $orderby ) = @_;
  3.  
  4. # Create the SQL statement
  5. $sql  = "SELECT a.*, b.desc_cd, b.cd_cd_val, b.cd_pcklst_type FROM isr2_aud_log a, pcklst b ";
  6. $sql .= "WHERE id_secr_rqst = $id_rqst";
  7. $status = $dbh->dbcmd( $sql );
  8.  
  9.    ### Execute the SQL statement
  10.    if (( $status = $dbh->dbsqlexec ) == &FAIL ) {
  11.          &error_log( $LOG_PATH, "get_rqsts",
  12.                          "dbsqlexec failed \n $sql");
  13.          return($status);
  14.    }
  15.    ### Get the results
  16.    if (( $status = $dbh->dbresults ) == &FAIL ) {
  17.          &error_log( $LOG_PATH, "get_rqsts",
  18.                          "dbresults failed \n $sql");
  19.          return($status);
  20.    }
  21.  
  22. # The following is the only way I could figure out how
  23. # to store and pass a complex data structure in perl
  24. ###############################################
  25.  
  26.    %arr = 0;
  27.    $query_idx=0;
  28.    @rqst_results = null;
  29.    while ( %arr = $dbh->dbnextrow(1) ) {
  30.      %{$rqst_results[$query_idx]} = %arr;
  31.      $query_idx++;
  32.    }
  33.  
  34.    # Free up the database work space
  35.    $dbh->dbcanquery;
  36.    $dbh->dbfreebuf;
  37.  
  38.    return @rqst_results;
  39. }
Mar 23 '07 #1
0 1702

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
1
by: Dark | last post by:
Im trying to insert a clob into the database and I get the following error. DBD::DB2::st execute failed: SQL0804N The application program input parameters for the current request are not...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
1
by: timdavis919 | last post by:
I'm trying to build some Russian web pages using Perl and MySQL. Toward that end, I have created a simple test case, which does not seem to work. Any help would be appreciated. I can...
0
by: brakesh | last post by:
Hi, I am trying to call a perl program (that connects a webserver database) from a php program via a webbrowser. For example : http://development.noaa.gov/test_exec.php?dataid=8313. The...
0
by: crawfordr | last post by:
Hello, I have created a perl script that connects to a specific socket (Ip address/port) using protocall of TCP. It is the server socket script. There is also coding to manage multiple handles by...
0
by: Rebles | last post by:
I'm writing a PERL script to access and insert rows into a Microsoft SQL. i'm using MS SQL Server Management Studio Express (2005) to architect tables and queries. I've inserted two records into...
1
by: Rebles | last post by:
Hi, I just posted this in the MS SQL Section, but maybe my problem is rooted in Perl, so it's more appropriate to post here instead (sorry for the double post) I'm writing a PERL script to...
31
by: happyse27 | last post by:
Hi All, I am doing a connection to database from perl to mysql via apache. Apache is configured correctly. Mysql username is root and password is mysql1, and database name is test. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.