No such thing as a small change | |
PerlMonks |
Question re SQL::Abstract (or something similar, whose existence I ignore!)by blazar (Canon) |
on May 18, 2006 at 15:38 UTC ( [id://550263]=perlquestion: print w/replies, xml ) | Need Help?? |
blazar has asked for the wisdom of the Perl Monks concerning the following question: <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?
Back to
Seekers of Perl Wisdom
|
|