Solved

unable to write Perl script by invoking small stored procedure to make simple calculation like addition,increment  value  then insert into oracle databsse table

Posted on 2008-10-15
2
372 Views
Last Modified: 2013-12-18
I was unable to write simple sample Perl script program which invokes small simple stored procedure to make simple calculation like addition,incrementing the value etc and then insert into oracle databsse table.I am new to Perl scripting as well as database.I installed active perl 5.1 and able to write hello world program on my vista operating system laptop.Oracle database i have on my laptop is Oracle Database 10g Express Edition.Once i am able to do this end to end test scenario from perl to stored procedure to inserting into oracle database i can extrapolate this concept to my larger scope migration project.Please help in this task by providing sample perl,stored procedure,insert statement etc code snippets,approach,links,resources.Thanks in advance.
0
Comment
Question by:gudii9
2 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
Comment Utility

#!/usr/bin/perl

use strict;

use DBI;
 

#replace database_name, username, and password as necessary

my $dbh = DBI->connect('dbi:Oracle:database_name', 'username', 'password')

 or die "Could not connect: $DBI::errstr";
 
 

#Run stored procedure

$dbh->do('BEGIN myPackage.myProcedure; END;')

  or die "Could not run stored procedure: $DBI::errstr\n";
 

#Insert just once

$dbh->do("INSERT INTO table (col1, col2) VALUES (5, 10)");
 

#Prepare to insert, then insert several times

my $sth = $dbh->prepare("INSERT INTO table (col1, col2) VALUES (?, ?)");

$sth->execute(5, 10);

$sth->execute('hello', 'world');
 

#Disconnect

$dbh->disconnect;

Open in new window

0
 
LVL 7

Author Closing Comment

by:gudii9
Comment Utility
thank you very much for your help.I appreciate it
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now