Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running sqlplus script from perl

Status
Not open for further replies.

Rajesh99

Programmer
Mar 17, 2003
43
0
0
US
I have a legacy code and need to run this from perl. I can not use DBI as this needs to fit in legacy.

system("sqlplus \/NOLOG <<EOF connect scott\/tiger\@store; select sysdate from dual;
exit
EOF ");

This does not work and keeps prompting me for help on sqlplus. Seems somewhere may be at << it fails and gives
wrong results.

Any idea how can I do this? Thanks.
 
Try outputting the command before shelling it, the << may need to be escaped.

What does the <<EOF do?

--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
<<EOF lells sqlplus run all tha sql commands that come upto EOF under.
Unfortnately I can create temp file etc so thai is the only option I have. I tried to escape << as \</< that did not work.

I only use perl once a while so not current with what else can I do.
 
I can't agree with this idea and I'm sure you could do this in perl/DBI but, nonetheless, if you insist on running sqlplus you could open a pipeline and "print" your sql to it.
Code:
open PIPELINE, "| sqlplus scott\/tiger\@store > output.txt" or die "Failed to open pipeline";
print PIPELINE "select sysdate from dual;";
close PIPELINE;


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top