Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: SQL::Abstract 'between' clause (about done)

by jethro (Monsignor)
on Nov 22, 2011 at 14:48 UTC ( #939467=note: print w/ replies, xml ) Need Help??


in reply to Re^4: SQL::Abstract 'between' clause (about done)
in thread SQL::Abstract 'between' clause (about done)

To create the data you see in the POD with scalar assignements you would have to write this:

$where{user}= 'nwiger'; $where{completion_date}{-not_between}= ['2002-10-01', '2003-02-06'];

What would be a problem is if you used this as well:

$where{completion_date}= 5;

Because $where{completion_date} can't be pointer to a hash and scalar value at the same time. But nothing prevents you from storing further scalar values or hash pointers in $where{thingy} or $where{stuff} or $where{completion_date}{depperstuff}

A big help might be to watch Data::Dumper output of %where after you execute each of the above statements


Comment on Re^5: SQL::Abstract 'between' clause (about done)
Select or Download Code
Replies are listed 'Best First'.
Re^6: SQL::Abstract 'between' clause (about done)
by Anonymous Monk on Nov 22, 2011 at 14:52 UTC
    Thanks but isn't my code doing what your code does?
    $where{$colname}{'-between'} = [$from,$to]; #my code where{completion_date}{-not_between}= ['2002-10-01', '2003-02-06'];#yo +ur code
    I though $from and $to would work as they contain the right values.

      I'm not talking about your script. I just answered your implied question "I don't see where I can use this functionality with the two choices you mentioned to pick from" in your last post.

      After looking at your script I see that the problem is that when you call process("DATE1=20111111:20111112"), your script will execute the first 'unless' (which will put a scalar value into $where{DATE1}) and then execute the last 'if' block (which will try to put a reference into $where{DATE1}).

      The problem is evident from your script output (it prints "normal value: 20111111:20111112" and it shouldn't do that, right?). If you had put a few Data::Dumper statements into the subroutine it would have been even more conspicuous.

      So evidently Anonymous Monk was right

        Thank you so much, this clear explanation helped me a lot. Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://939467]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (20)
As of 2015-07-29 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls