473,665 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl DBI database connection conversion

1 New Member
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 1715

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

Similar topics

3
2404
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 visitors to my Web site can access my database through my Web site at one time? Or does this mean that in my code I can only use 50 connections? and like
1
4900
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 valid. Reason code "103". If a host variable or S QLVAR in the SQLDA is invalid then: host variable/SQLVAR number = "5", SQLTYPE = "393", SQLLEN = "33", host variable/SQLVAR type = "INPUT". SQLSTATE=07002
4
6469
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 define the servername / hostname in my Perl Progrem.. Here is the code:
1
2592
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 successfully create a table in MySQL 4.1 with these commands (this creates a table with three rows; the three columns in each row are 1) an integer primary key, 2) a russian word, and 3) an english word): ...
0
1519
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 test_exec.php script that calls the perl program is as follows: <?php error_log("inside test_exec \n"); $dataid = $_GET; $cmd = "/usr/bin/perl /........../db_connect_psql_RS3.pl ". $dataid; error_log("dataid = $dataid\n"); exec($cmd); ?>
0
1601
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 usung the select() in the coding. This was needed due to the fact we expect a large volume of transactions at any given time on the client's side. The script's purpose is to connect to the client's port and listen for connections, accept the...
0
1391
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 my "Pools" table One from MS SQL Manager as a test, and another from my PERL script. The one inserted by MS SQL Manager shows up everytime. The row from my PERL script doesn't show up on MS SQL Manager and ONLY shows up on my PERL script and...
1
2275
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 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 my "Pools" table One from MS SQL Manager as a test, and another from my PERL script....
31
5699
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. when I type in url 127.0.0.1/cgi-bin/dbconn.pl, it showed internal server error 500. And errors in apache section a) below and errors in access. The samples table is created under test, residing in mysql database. Tried to triple check and...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8779
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.