diotalevi has asked for the wisdom of the Perl Monks concerning the following question:
I'm running the following function against a PostgreSQL database and a few tables to come up with a list of addresses that should be notified about messages that match a certain criteria. The most obvious thing for me to do was create a SQL SELECT statement which given some parameters would just return the right values. The issue I ran into is that I need to use the $message -> {'userid'} value more than once. The existing usage I've detailed looks wrong to me and I'm wondering if any of you have suggestions for either easing my mind or better ideas.
sub notify_users { my $message = shift; # Get the list of addresses to notify my @addr = @{$dbh -> selectall_arrayref(q[ SELECT addr FROM email, (SELECT userid FROM usernames WHERE 0 <> position(lower(username) IN ?) AND userid <> ? EXCEPT SELECT userid FROM ignore WHERE ignore_userid = ?) ids WHERE email.userid = ids.userid], undef, lc $message -> {'message'}, $message -> {'userid'}, $message -> {'userid'})}; # flatten the array $_ = $_ -> [0] for @addr; @addr = grep length(), @addr; return unless @addr; .... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Style: Passing the same value for multiple DBI placeholders
by dws (Chancellor) on Feb 06, 2003 at 19:17 UTC | |
|
Re: Style: Passing the same value for multiple DBI placeholders
by runrig (Abbot) on Feb 06, 2003 at 22:08 UTC | |
by diotalevi (Canon) on Feb 07, 2003 at 02:38 UTC | |
by bart (Canon) on Feb 08, 2003 at 00:59 UTC | |
|
Re: Style: Passing the same value for multiple DBI placeholders
by steves (Curate) on Feb 06, 2003 at 19:13 UTC | |
by diotalevi (Canon) on Feb 06, 2003 at 19:25 UTC | |
by steves (Curate) on Feb 06, 2003 at 19:35 UTC |