in reply to Re^2: Substitute "Yes" for "1" in mysql query output?
in thread Substitute "Yes" for "1" in mysql query output?

In any event, I see what you are doing. This will not produce any printout at all if $preauth is not 0 or 1 (as you alluded to)

#!/usr/bin/perl use strict; use warnings; my $preauth=3; print qw(No Yes)[$preauth]; # No output at all! print ($preauth eq '1' ? "Yes" : "No"); # Prints No
As a practical matter, I use SQLite for all my DB work unless I need to use another DB (and that can happen for a lot of reasons). SQLite does not have a boolean type..it is only an int. So a value like "3" could conceivably show up. My code only recognizes '1' as the 'True' value. No insurance company or provider is going to work with a DB that does not have a boolean data type.

It appear to me that Re: Substitute "Yes" for "1" in mysql query output? is the way to go... Put this yes/no decision into the SQL solution space.

Replies are listed 'Best First'.
Re^4: Substitute "Yes" for "1" in mysql query output?
by soonix (Chancellor) on Jan 26, 2017 at 11:01 UTC
    Yes, shortly after I posted, i saw poj's reply and thought "Hey, that's even better!". The only nag was, that it's not Perl :-)

    On the latter point (and your point), there may still be different views, how the database distinguishes true from false, and how Perl (and/or the respective script) does that. The best way to minimize conflicts seems to be laid out over there (CHECK constraint on the column). But of course, a real Boolean column type would be better.

      I didn't know about: CREATE TABLE foo(mycolumn BOOLEAN NOT NULL CHECK (mycolumn IN (0,1)));

      but we agree, "But of course, a real Boolean column type would be better".