List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 13 2000 10:25pm
Subject:Re: forcing the SET type column to return the decimal value
View as plain text  
At 11:12 PM +0200 10-13-2000, Stas Bekman wrote:
>On Fri, 13 Oct 2000, Paul DuBois wrote:
>  > Is there something about karma|0 that you don't like?
>>  It's perfectly acceptable.  So is karma+0.
>
>It looks like a hack, and it's not obvious to the reader of my code what
>is being returned.
>
>karma+0 is not different than karma|0, at least the later gives the hint
>that the variable must be a of the SET type (because of the bit-wise OR).

You could put a comment in your code. :-)

>
>Of course it works for me, but I just thought that there should be an
>operand that tells mysql to return the data as a number or string
>explicitly.

It's unnecessary, given that +0 or |0 work.

>
>This remind me of perl variables where scalars are always has both
>types: string and numerical, and the appropriate value is returned
>according to the context.
>
>The only request that I have is to add this note to the SET section in the
>mysql documentation. I didn't come up with this trick right away, because
>I was sure that mysql has a special function for that, so I've spent quite
>a lot of time looking for it. When I gave up I've found the solution by
>trial and error.

Done.  Thanks for the suggestion.

-- 
Paul DuBois, paul@stripped
Thread
forcing the SET type column to return the decimal valueStas Bekman13 Oct
  • Re: forcing the SET type column to return the decimal valueStephen Vance13 Oct
  • Re: forcing the SET type column to return the decimal valuePaul DuBois13 Oct
    • Re: forcing the SET type column to return the decimal valueStas Bekman13 Oct
      • Re: forcing the SET type column to return the decimal valuePaul DuBois14 Oct
        • Re: forcing the SET type column to return the decimal valuePete Harlan15 Oct
          • Re: forcing the SET type column to return the decimal valueDon Read15 Oct