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

Scott Walters scott at illogics.org
Wed Mar 15 18:06:39 PST 2006


> 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