You missed the "case when" part.
See "The CASE Expression" : http://www.sqlite.org/lang_expr.html

On Mon, Jun 21, 2010 at 2:28 AM, Sam Carleton
<[email protected]> wrote:
> Igor,
>
> You lost me;)  I think I might be taking you too literally, here is
> what I tried:
>
> SELECT FolderId, ImageId, instertedon
>  FROM V_FAVORITES_SELECTED
> WHERE instertedon > julianday(@time)
>   THEN findImage(@rootPath, FolderId, ImageId) ELSE 0 END;
>
> The prepare statement didn't much like something around the THEN statement.
>
> Sam
>
> On Sun, Jun 20, 2010 at 9:33 AM, Igor Tandetnik <[email protected]> wrote:
>> Sam Carleton <[email protected]> wrote:
>>> This works great.  The issue is that the image returned might NOT
>>> exist anymore, so I created an extension function to return 1 if it
>>> exists, 0 if it doesn't, findImage( RootPath, FolderId, ImageId).
>>> Then I added to the select statement like this:
>>>
>>> SELECT FolderId, ImageId, instertedon
>>>  FROM V_FAVORITES_SELECTED
>>> WHERE instertedon > julianday(@time) AND findImage( @rootPath,
>>> FolderId, ImageId) = 1
>>>    LIMIT 1
>>>
>>> The findLargeImage gets called for EVERY row.  I was hoping there
>>> would be some sort of short-circuit evaluation, like there is in C/C++
>>> and many other languages.  Is there some way I could rewrite the query
>>> to short-circuit so that findImage()
>>
>> Try something like this:
>>
>> WHERE case when instertedon > julianday(@time)
>>    then findImage(@rootPath, FolderId, ImageId)
>>    else 0 end;
>>
>> --
>> Igor Tandetnik
>>
>> _______________________________________________
>> sqlite-users mailing list
>> [email protected]
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to