Home » SQL & PL/SQL » SQL & PL/SQL » DBMS_SCHEDULER and perl script (Oracle 11.2, linux)
DBMS_SCHEDULER and perl script [message #625852] Wed, 15 October 2014 01:26 Go to next message
rrk1
Messages: 4
Registered: October 2014
Junior Member
Hi all,
I had written a script in Korn shell which called 2 pl/sql procedures. This shell script was called from the DBMS_SCHEDULER and it worked fine. But later I was asked to change it to perl, as we had to move to windows based machine. The perl script ran fine from the command prompt but when I tried this from the scheduler, the job failed with "ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory" error. No extra messages were found in all_scheduler_job_run_details. While debugging I realized if I commented out DB related commands the job ran fine. I tried including the path to libraries (see entries in green), yet it fails. Probably missing some more libraries. I have attached apart of my perl script below. Please advise.

Appreciate any help or suggestions.

Thanks in advance


#!/usr/bin/perl
use DBI;
use strict;
$ENV{'ORACLE_HOME'} = '/product/app/11.2.0/db_1';
$ENV{'ORACLE_SID'} = 'XXX';
$ENV{'LIB_PATH'} = '$ORACLE_HOME/lib';
$ENV{'PATH'} = '$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/opt/perl5_64/lib/site_perl/5.18.2/aix-thread-multi-64all:.$LIB_PATH
$ENV{'LD_LIBRARY_PATH'} = '$GG_HOME:$LIB_PATH:/usr/opt/perl5_64/lib/site_perl/5.18.2/aix-thread-multi-64all';

#my ( $inst, $user, $pass ) = @ARGV;
my $inst = "XXX";
my $user = "aaa";
my $pass = "aaa";
# So we don't have to check every DBI call we set RaiseError.
# See the DBI docs if you're not familiar with RaiseError.
# AutoCommit is currently encouraged and may be required later.
print($inst, $user, $pass, "\n" );
my $dbh = DBI->connect( "dbi:Oracle:$inst", $user, $pass,
{ AutoCommit => 0, RaiseError => 1, PrintError => 0 } )
or die "Unable to connect: $DBI::errstr";
exit 0;

Re: DBMS_SCHEDULER and perl script [message #625855 is a reply to message #625852] Wed, 15 October 2014 02:05 Go to previous messageGo to next message
John Watson
Messages: 8979
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum. Please read our OraFAQ Forum Guide and please read How to use [code] tags and make your code easier to read

First, what operating system are you using? Your title says Linux, the question says Windows, and those paths in green look like AIX.
Second, what do you want to do? It sounds as though from within the database you want to run a shell script that logs on to the database, which can't be right.

update: typos

[Updated on: Wed, 15 October 2014 02:06]

Report message to a moderator

Re: DBMS_SCHEDULER and perl script [message #625858 is a reply to message #625855] Wed, 15 October 2014 02:24 Go to previous messageGo to next message
rrk1
Messages: 4
Registered: October 2014
Junior Member
Sorry for the confusion. My current OS is AIX and I am trying to run a Perl script from DBMS_SCHEDULER. I am working currently on a AIX box but eventually this script might need to run on a windows platform. Hence I need a platform independent script. Which is why I am moving to Perl.

As for the script, I have attached only a part of the Perl script as it is failing at the login itself. Actually after logging into the database, I need to run a pl/sql procedure, which I have not included in the sample code.

Please let me know if there are any other questions.
Re: DBMS_SCHEDULER and perl script [message #625861 is a reply to message #625858] Wed, 15 October 2014 02:32 Go to previous messageGo to next message
John Watson
Messages: 8979
Registered: January 2010
Location: Global Village
Senior Member
Why do you not use the Scheduler to run the PL/SQL? Much easier and more secure.
Re: DBMS_SCHEDULER and perl script [message #625863 is a reply to message #625861] Wed, 15 October 2014 02:41 Go to previous messageGo to next message
rrk1
Messages: 4
Registered: October 2014
Junior Member
Yes. that is correct. But beside running the pl/sql procedure it has to run some Oracle Golden Gate commands to perform initial loading of data. I donot know how to include the GG commands in pl/sql. Hence I have to run a Perl script which will call both the pl/sql procedure and the Oracle GG initial Load script.

Please advise. If there is a better option, please let me know.
Re: DBMS_SCHEDULER and perl script [message #625888 is a reply to message #625863] Wed, 15 October 2014 08:44 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
I have done PERL programming for many years, but I have never tried invoking any Perl script directly from DBMS_SCHEDULER.
When you establish environmental variable & do not "export" it, the environmental variable can not be utilized by any subsequent commands.
I don't know whether this applies inside Perl scripts, too.

I am not convinced that this error involves any library directory.
Re: DBMS_SCHEDULER and perl script [message #625889 is a reply to message #625858] Wed, 15 October 2014 09:00 Go to previous messageGo to next message
John Watson
Messages: 8979
Registered: January 2010
Location: Global Village
Senior Member
rrk1 wrote on Wed, 15 October 2014 08:24
<snip>
beside running the pl/sql procedure it has to run some Oracle Golden Gate commands to perform initial loading of data. I donot know how to include the GG commands in pl/sql. Hence I have to run a Perl script which will call both the pl/sql procedure and the Oracle GG initial Load script.
Well, I would do it as a job chain: one jobs to run the pl/sql then another to run the GG stuff. To invoke the GG code, just use an external job that invokes your shell interpreter with the name of the script as an argument.

--update: quoted the wring message.

[Updated on: Wed, 15 October 2014 09:02]

Report message to a moderator

Re: DBMS_SCHEDULER and perl script [message #625898 is a reply to message #625889] Wed, 15 October 2014 14:04 Go to previous messageGo to next message
rrk1
Messages: 4
Registered: October 2014
Junior Member
some more info in the logs now.
STANDARD_ERROR="install_driver(Oracle) failed: Can't load '/usr/opt/perl5_64/lib/site_perl/5.18.2/aix-thread-multi-64all/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: Could not load module /usr/opt/perl5_64/lib/"
15-OCT-14 06.30.11.915735 PM +00:00

Does this help further in finding a solution? Please help
Re: DBMS_SCHEDULER and perl script [message #625900 is a reply to message #625898] Wed, 15 October 2014 15:24 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
I am going to guess what BlackSwan says is happening here. I believe (but I am usally wrong when guessing) that the call to the script has no idea of the environment at all. I think you are going to have to set all those environment variables in the script itself.
You can test this by echoing them out to a file and see the results.
Re: DBMS_SCHEDULER and perl script [message #625901 is a reply to message #625900] Wed, 15 October 2014 15:28 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>You can test this by echoing them out to a file and see the results.

I use below for testing batch scripts

#!/bin/bash
/usr/bin/env > /tmp/capture.env
# rest of actual script starts below here
Previous Topic: complex view
Next Topic: Merge collections ?
Goto Forum:
  


Current Time: Mon Jul 21 18:30:43 CDT 2025