Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Perl Code: Perl SQL Update Example Jump to:  
Category: >> Perl Code >> Perl SQL Update Example Bookmark and Share

<< lastnext >>

Snippet Name: Perl SQL Update Example

Description: Updating a record in a database with perl and the DBU module.

Comment: (none)

Language: PERL
Highlight Mode: PERL
Last Modified: March 05th, 2009

#!/usr/bin/perl
 
# Use the DBI module
USE DBI;
 
# PERL SQL Update Example 
 
 
MY $dsn = 'DBI:mysql:dictionary:space.powweb.com';
MY $db_user_name = 'ssadmin';
MY $db_password = 'dictionary';
MY $password = "dictionary";
 
 
# Connect to the database
# Note this connection can be used to 
# execute more than one statement
# on any number of tables in the database
 
MY $dbh = DBI->connect($dsn, $db_user_name, $db_password) || DIE "Connect failed: $DBI::errstr\n";
 
 
 
# Create the statement.
 
$stmt = "UPDATE Player_Stats SET total_games_played = '199' WHERE username LIKE '%joe'";
 
# Prepare and execute the SQL query
$sth = $dbh->prepare($stmt) || DIE "prepare: $stmt: $DBI::errstr";
 
# Execute the statement
$sth->execute();
 
$sth->finish();
$dbh->disconnect();
 
 
PRINT "Content-type: text/html\n\n";
 
 
PRINT "Done!";
 
EXIT;
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 194 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?