On Wed, Aug 15, 2001 at 11:30:44AM -0400, Philip Mak wrote:
> I've had an ongoing problem where the SQL statements in my perl programs
> come out rather messily.
>
> Does anyone have specific and general suggestions on how to write embedded
> SQL code cleanly in perl programs? Here's an example of an ugly piece of
> SQL statement I wrote recently:
>
> $dbh->do
> ("REPLACE INTO services SET friendly=".$dbh->quote($friendly).
> ", parent=".$dbh->quote($parent).
> ", intentional=".$dbh->quote($intentional).
> ", address=INET_ATON(".$dbh->quote($address).")".
> ", port=".$dbh->quote($port).
> ", timeout=$timeout".
> ", priority=".$dbh->quote($priority));
How about something like this?
my $SQLstatement = qq{
select alias, ip, canonical, ostype from } . $table . qq{ where alias like
\"%$alias%\"
};
my $sth = $dbh->prepare($SQLstatement);
--
Any technology distinguishable from magic is insufficiently advanced.
TopQuark Software & Serv. Contract programmer, server bum.
[EMAIL PROTECTED] Give up Spammers; I use procmail.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php