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.
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 ONLY if the INSERT query isn't commented out.
For me, this is the second day of troubleshooting . Does anybody have any insight? - $dbHandle = S_dbConnect($hostname, $database, $username, $password, $port);
-
-
$query = qq{INSERT INTO Pools (site_ID, pool_name, last_job_ID)
-
VALUES(1, 'CSE_IAL_intnb6', 0)};
-
print "$query\n";
-
-
$dbHandle->do($query);
-
-
$query = qq{SELECT * FROM Pools};
-
print "$query\n";
-
-
$m_sth = S_dbExecute($dbHandle, $query);
-
-
while(my $row = $m_sth->fetchrow_hashref()) {
-
print "$row->{pool_ID}\t$row->{site_ID}\t$row->{pool_name}\t$row->{last_job_ID}\n";
-
}
-
print "END\n";
-
-
######################################################################
-
# Subroutine: S_dbConnect
-
# Function:
-
# Creates a database connection to the database specified by the global
-
# variables in the database initialization section at the top of this
-
# file.
-
# Variables:
-
# $g_serverName contains the name of the database server.
-
# $g_dbName contains the name of the database on the server.
-
# $g_interfacesFile contains the path to the interfaces file which is
-
# required by Perl::DBI.
-
# $g_dbUsername contains the username which will be used to access the DB.
-
# $g_dbPassword contains the password used to authenticate with the DB.
-
# Returns:
-
# $H_DB is the database handle established by the database connection
-
#
-
######################################################################
-
-
sub S_dbConnect{
-
my ($server,$db,$user,$password,$port) = @_;
-
print "Trying to connect to Database... " if ($debug) ;
-
$H_DB = DBI->connect("dbi:Sybase;server=$server:$port;database=$db",$user,$password, 'Sybase' )
-
|| die "DBI: Unable to connect to the database - $DBI::errstr\n";
-
$H_DB->{'RaiseError'} = 1;
-
print "Connected to the Database\n" if ($debug) ;
-
return $H_DB;
-
}
-
-
######################################################################
-
# Subroutine: S_dbExecute
-
# Function:
-
# Executes a SQL query on an already established database connection.
-
# Variables:
-
# $m_sql contains the SQL query to be executed on the database.
-
# $H_DB is the database handle the sql query is to be executed on.
-
# Returns:
-
# $m_sth is the handle for the data returned by the database.
-
#
-
######################################################################
-
-
sub S_dbExecute{
-
my ($H_DB, $m_sql) = @_;
-
my $m_sth = $H_DB->prepare($m_sql);
-
# if prepare fails, sth is undefined
-
if (!defined $m_sth){
-
print "Error preparing sql record: " . $H_DB->errstr .my @ret_val = (1,$m_sth);
-
return @ret_val; "\n";
-
}
-
-
# sth returns true if it succeeds
-
if ($m_sth->execute()){
-
return $m_sth;
-
}
-
# sth returns false if it fails
-
else{
-
die "Error quering Database\n";
-
}
-
}
The two functions above are not mine, they are borrowed
Here are the results: - filc0201> ./test_db2.pl
-
Trying to connect to Database... Connected to the Database
-
INSERT INTO Pools (site_ID, pool_name, last_job_ID)
-
VALUES(1, 'CSE_IAL_intnb6', 0)
-
SELECT * FROM Pools
-
22 1 test 0
-
30 1 CSE_IAL_intnb6 0
-
END
Here is my server's info: - filc0201> uname -a
-
Linux filc0201 2.6.5-7.276.PTF.196309.1-smp #1 SMP Mon Jul 24 10:45:31 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
-
filc0201> cat /etc/issue
-
-
Welcome to SUSE LINUX Enterprise Server 9 (x86_64) - Kernel \r (\l).
1 2279
Ah, nevermind,
I needed to add a
$dbHandle->commit(); for the changes to take effect.
Also, Does anybody know if there is a way to retrieve the auto incremented ID in the same SQL statement? It would help cut down the over head in my script.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ben moretti |
last post by:
hi
i'm learning python, and one area i'd use it for is data management in
scientific computing. in the case i've tried i want to reformat a data
file from a normalised list to a matrix with some sorted columns. to
do this at the moment i am using perl, which is very easy to do, and i
want to see if python is as easy.
so, the data i am using is some epiphyte population abundance data for
particular sites, and it looks like this:
|
by: Andrew |
last post by:
Hi All,
Have come across something weird and am after some help.
Say i run this query where rec_id is a column of table arlhrl,
select * from arlhrl where rec_id >= 14260
This returns to me 2 records with rec_id's of 14260 and 14261
|
by: Christopher Murtagh |
last post by:
Greetings,
I'm trying to write a pl/perl function that will return multiple rows.
I've looked all over the web and only found vague references as to how
to do this (some said it was possible, and some said it wasn't but it
was for older versions of Postgres).
Basically I would *love* to be able to do something like this:
SELECT some_id
|
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:
|
by: Dave |
last post by:
Apologies if this has come up before, but I can't find it if it has. I
am fairly new to .Net and am having problems with ghosts in the
datagrid.
Basically I have a find screen that accepts search criteria, then
interrogates a database to find all matching records. These are put
into a dataset, which has a dataview that is used as the datasource of
my datagrid, which is read only. The idea is that the user selects
which record they...
| |
by: Shawn Milo |
last post by:
I'm new to Python and fairly experienced in Perl, although that
experience is limited to the things I use daily.
I wrote the same script in both Perl and Python, and the output is
identical. The run speed is similar (very fast) and the line count is
similar.
Now that they're both working, I was looking at the code and wondering
what Perl-specific and Python-specific improvements to the code would
look like, as judged by others more...
|
by: aktar |
last post by:
Ok, I've been spending hours trying to catch this "phantom" bug but just cant locate it.
This is the code
<?php
//this is an array containing the filed attribute
$field = array();
$field = 'Description';
|
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...
|
by: happyse27 |
last post by:
Hi All,
I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c.
Not sure where went wrong as the web page displayed internal server error.
Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |