On Wednesday, May 30, 2012 12:12:16 PM UTC-7, lkfken wrote:
>
> My goal is to retrieve a dataset based from a combination of a LIKE 
> operator (since MSSQL doesn't support regex):
>
> To illustrate my point, here is a definition prototype:
>
>   def_dataset_method(:commercial_members) do
>     filter(:mem_lob.like('1%'), (:mem_lob.like('2%')).sql_or)
>   end
>
> "return a filtered dataset with mem_lob are like 1* or 2* "
> **
> The above would raise an exception.
>
> In contrary, the following (similar) definition works:
>   def_dataset_method(:disenrolled) do
>     filter({ :disenr => 'D', :group_num => ' ' }.sql_or)
>   end
>
> It looks like the "sql_or" method cannot handle "LIKE", and only hash is 
> supported.
>
> So how to do I achieve my goal?  Thank you.
>

sql_or is designed for use with condition specifiers (hashes, arrays of two 
element arrays), it's not defined on datasets.  You should probably use the 
| method on the SQL::Expression produced by the #like method:

  def_dataset_method(:commercial_members) do
    filter(:mem_lob.like('1%') | :mem_lob.like('2%'))
  end

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/Muz8GrHVCAsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to