I guess you are looking for something smarter than this :)
#!perl
use strict;
use DBI;
use SQL::Abstract::More;
my $sqla = SQL::Abstract::More->new();
my $case = q!
CASE
WHEN record.is_public = 'Yes' THEN 'public'
WHEN EXISTS ( SELECT 1
FROM permissions
WHERE permissions.rec_id = record.id AND user_id = ? )
THEN 'accessible'
ELSE
'private'
END
as viewable!;
my ($sql,undef) = $sqla->select(
-columns => [$case,'record.id','record.display_name'],
-from => 'record',
-where => { 'record.id' => 1 }
);
print $sql;
poj
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.