Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 2000 total points
ID: 22726102

#!/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
ID: 31506512
thank you very much for your help.I appreciate it
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

704 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