473,396 Members | 1,875 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,396 software developers and data experts.

verifying mysql writes (perl)

Hi

What is a proper way of verifying that a mysql write was successfull,
and to retry if it wasnt?

In my perl script I add records through:

my $dbh=DBI->connect($dsn, $db_user_name, $db_password);
my $sth=$dbh->prepare("insert into TABLE (X, Y, Z) values ('1', '2',
'3')");
$sth->execute;
$sth->finish;

I have noticed that from time to time this fails, due to limitations
of my webhost. I thus want to do a check after the write, that it
actually happened, and if not redo.

Suggestions?

Thanks! M
Jul 20 '05 #1
1 3205
Marcus wrote:
What is a proper way of verifying that a mysql write was successfull,
and to retry if it wasnt?


DBI methods return values. You should check these to get some
indication of success or failure.

my $dbh=DBI->connect($dsn, $db_user_name, $db_password);
if (!defined($dbh))
{
croak($DBI::errstr);
}

my $sth=$dbh->prepare("insert into TABLE (X, Y, Z) values ('1', '2', '3')");
if (!defined($sth))
{
carp($dbh->errstr);
return();
}

my $rows_inserted = $sth->execute;
if (!defined($rows_inserted))
{
carp($dbh->errstr);
return();
}

# Operation successful, and $rows_inserted should be a
# positive integer, indicating the number of rows affected
# by the operation. This should be 1 in this case.

# $sth->finish;
# The finish method is for closing an open query before all
# rows of its result set have been fetched; it is not necessary
# after executing a SQL INSERT statement.

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marc Poulhiès | last post by:
Hi, I'm trying to build a system using HTTPS with python clients that have to verify the server's identity. From the Python document, it seems that the server's certificate is not veryfied, and...
4
by: Michael | last post by:
I'd like to write a program to verify the consistency between various database replicas in our environment. The rules are as follows: - I'm given two servers, each with a database - I don't...
1
by: smsabu2002 | last post by:
Hi, I am facing the build problem while installing the DBD-MySql perl module (ver 2.9008) using both GCC and CC compilers in HP-UX machine. For the Build using GCC, the compiler error is...
9
by: Carter Smith | last post by:
http://www.icarusindie.com/wiki/index.php/Server-Side_Javascript_Check Sample source included This method requires that your pages are PHP enabled and you have mySQL. Although I suppose you...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
2
by: moller | last post by:
Im looking in to the possibility of moving from mySQL to an access database. My reasons are: (1) Database is single user. (2) Database local on users PC. (3) Database has only 8 tables where 4...
67
by: Bob Powell | last post by:
To whom it may concern: I find the recent articles in various trade publications a little disturbing due to the lack of PostgrSQL mention. I continue to see articles about how IBM may be...
3
by: menzies | last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a...
1
by: Megi | last post by:
welcome, I input data form file to mysql with command: load data local infile.. The efect is that the data are duplicated or trippled..etc with every re-loading the script, but I need to load...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.