Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I use the following way to call oracle stored procedure in perl script, how can I use the same way to call oracle function ?

$str = "sqlplus -s <<-eof \n" . "$db_login \n" . "WHENEVER SQLERROR EXIT FAILURE; \n" . "EXEC @ARGV[0]; \n". "exit; \n". "EOF\n"; $return_code = system($str);

How can I call oracle function in perl script without using DBI and DBD ?

Thanks

Code tags added by GrandFather

Replies are listed 'Best First'.
Re: how to call oracle function from perl script
by grinder (Bishop) on Mar 30, 2008 at 09:30 UTC

    But you can call an Oracle function that way. At least I think you can; with the excellent formatting you have applied to the code, it is difficult to be sure.

    If you want to capture the output of sqlplus, you will have to use backticks instead of system, in which case you would write:

    my @ret = `$str`;

    If you want fine-grained control over sqlplus, you should look at IPC::Open3 and/or IPC::Run. But at that point you will be adding so much complexity to the code, you would be much better off with just using DBI anyway.

    • another intruder with the mooring in the heart of the Perl