Re: [exim] handling nulls in SQL lookups

Top Page
Delete this message
Reply to this message
Author: Serge Demonchaux
Date:  
To: exim-users
Subject: Re: [exim] handling nulls in SQL lookups
In my "router":

virtual_alias:
  debug_print = "R: virtual_alias for $local_part@$domain"
  driver = redirect
  allow_fail
  allow_defer
  data = ${lookup sqlite{/etc/exim/exim_CentralDB.sql \
    SELECT destination FROM aliases \
        WHERE origine='${local_part}@${domain}'}}
  file_transport = address_file
  pipe_transport = address_pipe
  headers_add = "X-Sd3L-VAlias: $local_part@$domain"


Le Dimanche 23 Juillet 2006 09:23, Ian P. Christian a écrit :
> I'm doing as follows:
>
>
> SPAM_COUNT    = SELECT SUM(spam_score) FROM spam WHERE host =
> '${quote_sqlite:$sender_host_address}' AND created_at > (${tod_epoch} -
> 300);

>

SPAM_COUNT    = /path/to/sqlite.db SELECT SUM(spam_score) \
    FROM spam WHERE host ='${quote_sqlite:$sender_host_address}' \
    AND created_at > (${tod_epoch} -300);


>   warn
>           set acl_m3  = ${lookup sqlite {SQLITE_DB SPAM_COUNT}{$value}}
>           log_message = Spam total: $acl_m3

>
>
> However, this will obviously return nothing if the host has never mailed
> before, and the 'Spam total' reports as NULL.
>
> Other then hacking the SQL statement to return a 0 (which I've
> previously done with MySQL, but can't get sqlite to play nice) - is
> there something I'm missing to default the value to 0 when there's a null?
>
> Thanks,
>
>
> Ian
>
>
> btw - exim seems to do NO error reporting with sqlite problems - if the
> database file is invalid, if the permissions are wrong, or if the query
> is wrong, there are no errors reported - I'll have to bug about this at
> some point.
>
> --
> Ian P. Christian ~ http://pookey.co.uk


--
________________________________________________________
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 9341E467457C15CB

 °v°       Serge Demonchaux
/(_)\  <serge@???>
^ ^  
________________________________________________________
<http://eucd.info/petitions/index.php?petition=2>