in reply to Re^2: difficulty with SQL::Abstract '-in' clauses
in thread difficulty with SQL::Abstract '-in' clauses

Sarah:

The way I'd approach that would be to first make your code use the '-in' hash element as a hash array, rather than a fixed-format string. Next, I'd do the same with the '-like' element (I'm assuming it's existence from your question). Then, to use it, I'd split the string on the delimiter (|) to make a list and put each item on the appropriate list. Something like this (untested):

my @vals = split /\|/, $DocumentReference; for my $V (@vals) { if ($V =~ /\*/) { $V=~s/\*/%/; push @{$where{DocumentRef}{'-like'}}, $V; } else { push @{$where{DocumentRef}{'-in'}}, $V; } }

Then, when it comes time to use it, you can create your IN clause like:

$SQL .= ' IN (' . join(", ", @{$where{DocumentRef}{'-in'}}), ') ';

and your LIKE clauses something like this:

$SQL .= join(' OR ', map { "LIKE $_ " } @{$where{DocumentRef}{'-like'} +});

Note: You'll still need to ensure that the values are all quoted properly, and that you have the proper conjunctions between all your clauses, error handling, etc. etc.

...roboticus

Update: Moved last paragraph (it was accidentally in code tags...)