[Phoenix-pm] Running a SQL program within PERL DBI

Metz, Bobby W, WCS bwmetz at att.com
Wed Mar 15 18:18:02 PST 2006


Hey thanks for the "&" tip.  Old habit I guess since the folks I learned
from used it in all their code and I've never read up on Perl 5 calls to
find out otherwise.  Thought I knew what I was doing :-)

So, just "@results = mysql_mod::execute($my_sql_file);" does the trick?

Bobby

-----Original Message-----
From: Scott Walters [mailto:scott at illogics.org]
Sent: Wednesday, March 15, 2006 7:07 PM
To: Metz, Bobby W, WCS
Cc: Loo, Peter # PHX; phoenix-pm at pm.org
Subject: Re: [Phoenix-pm] Running a SQL program within PERL DBI


> use mysql_mod;
> $my_sql_file = "blahblahblah"
> @results = &mysql_mod::execute($my_sql_file);

Bobby, Peter,

I'd like to encourage you to drop the &, though.  You needed it in Perl
4;
in Perl 5, you don't, but gives you a funky Perl 4 compatability mode
where prototypes are disabled.  You don't want this.  It breaks things.

> foreach $line (@results)
>  {
>   # pattern match whatever
>   # call other routines
>   # etc.
>  }
> 
> This could save you time cut/pasting or re-writing the sqlplus call,

Yes, there's absolutely no reason why you can't put SQL in a file
rather than hard-code it into a program.  

> redirection, or whatever, each and every time you have a new script
> need.  Again, no point trying to parse the .sql file to perform the
> queries in DBI...just process the output from sqlplus.

... and I posted something that would fork off a process and run it
in the SQL shell.

> 	As to leaving the group...give us another chance.  I agree with
> Brock that your original problem statement wasn't well defined and I

If it makes you feel any better, I make about $5/hour >=)

-scott


More information about the Phoenix-pm mailing list