I am working on a slide show feature.  The logic is based on time,
there are a set of image metadata (folderId and filename) add to the
DB, the insertion time is also saved.  The client calls the
getNextSlideShow() method to get the next image.  The current select
statement is:

SELECT FolderId, ImageId, instertedon
  FROM V_FAVORITES_SELECTED
WHERE instertedon > julianday(@time)
    LIMIT 1

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() is only called on the files that
are greater @time and it stops once the function returns true one
time?

Sam
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to