<premise>
I have never received any formal education about relational databases. I think I'm a decent Perl programmer, though. Now my current work requires me to work a lot with relational db's. Moreover I don't know the structure of our own db('s) which is also an obstacle. However I'm slowly learning and thus beginnig to cope with both problems. Generally I try to stay "on the Perl" side as much as possible, rather than to delve into SQL.
</premise>
Now, I'm often using SQL::Abstract to build queries. Needless to say, it greatly helps me. But I have a problem: when all of the values are determined, SA gives me a $where clause with placeholders and a @bind array with the corresponding values. So far, so fine. OTOH sometimes I'd need, so to say, to leave some values unspecified at clause-buildup-time.
The reason why I want to do what I've described at the end of the last paragraph is that I'm writing a closure around a lexical $sth (that I'm using as a callback), and in the arguments passed to $sth->execute() I want to include some arguments passed to the closure itself.
Let me get straight: I do have a solution to the problem. But I find it inelegant, not terribly reliable and on the whole unpleasant. Currently I give to some of the values passed to the where() method a special formatting and I later reprocess @bind with an ad hoc sub to substitute the "unspecified" values with those I want.
All in all I'd like something that would hardcode in $where all the values that are, say, defined and put a placeholder if a value is undef.
Any idea?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |