FAQ

On Wed, 14 May 2003 09:40:25 -0400 Sweth Chandramouli wrote:

I'm still trying to debug the coredump problem that I'm
getting with DBD::Oracle on HP-UX 11.00 (about which I posted to the
list a few days ago), but in the interim I'm trying to find a kludge
to get this system up and running. One idea that occurred to me, and
which immediately made me recoil in horror but which I probably need
to explore anyway since it might be my only solution at the moment,
is to convert all of my DBD::Oracle calls to calls to the native Oracle
sqlplus binary (which works fine on the system in question). Before
I go down that path, though, I thought I'd see if anyone knew of any
prior art in that area that I might be able to reuse; CPAN didn't seem
to have anything of relevance. If anyone has other suggestions for
temporary workarounds while I try to figure out the real problem (or
suggestions for figuring out that real problem, for that matter), that
would also be greatly appreciated.
It depends on how complex the actions you need are. A few years ago,
I wrote a module that did a fairly good job of encapsulating sqlplus
in a few 10K. I generally put a known value in the first column so I
could strip out the data lines without worrying about what else was
present.

I used IPC::Open3 to manage passing statements to SQL*Plus and
receiving the results, but it was often better to include a SPOOL
statement in the input stream and read the result from the spool file.
I normally added a PROMPT after the SELECT with a clear end marker.

This is mostly from memory because it's been a while since I used it.

use IPC::Open3;
my ( $in, $out );
my $pid = open3( $in, $out, 0, "sqlplus $uid/$pwd\@$inst" );

# Short results
print $in "SELECT 'MARK' x, * FROM DUAL;\nPROMPT MARK END\n";
while ( <$out> ) { next if ! s/^MARK\s+//; last if /^END/; print $_; }

# Long results
my $file = "/tmp/$$.out":
print $in <<SQL
SPOOL $file
SET LINESIZE 500
SET TRAILING ON
SELECT 'MARK' x, table_name, column_name FROM user_tab_columns;
PROMPT MARK END
SPOOL OFF
SQL
open( FILE, $file ) or die "Can't open $file, $!\n";
while ( <FILE> ) { next if ! s/^MARK\s+//; last if /^END/; print $_; }

--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupdbi-users @
categoriesperl
postedMay 14, '03 at 1:40p
activeMay 15, '03 at 2:55a
posts2
users2
websitedbi.perl.org

People

Translate

site design / logo © 2022 Grokbase