Re: [sqlite] sqlite core function question
Hi Jay, or better yet, I expected this to work, using the modulo operator %: SELECT x - x % 1; Isn't that evaluated left to right? x-x = 0 0 %1 = 0 I don't think so. Well, yes, it is generally evaluated left to right, but mod has precedence of minus, so it gets evaluated first. So even putting in brackets we get the same answer: sqlite> select 3.44 - (3.44 % 1); 3.44 sqlite> select 3.44 - 3.44 % 1; 3.44 Tom - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite core function question
On 1/31/07, T&B <[EMAIL PROTECTED]> wrote: or better yet, I expected this to work, using the modulo operator %: SELECT x - x % 1; Isn't that evaluated left to right? x-x = 0 0 %1 = 0 -- -- The PixAddixImage Collector suite: http://groups-beta.google.com/group/pixaddix SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com
Re: [sqlite] sqlite core function question
From: "T&B" <[EMAIL PROTECTED]> Hi Jeff, I've encountered some functions that apparently aren't supported by SQLite So have I, such as replacing occurrences of an inner string. so I've created my own I've yet to figure out/try that. Is there a library somewhere of prebuilt functions we can add? Hi Tom, I'm not aware of any "prebuilt function library". In my case, I'm developing my app in Tcl. There creating and registering new SQL functions is simple - trivial even. So, whenever I run into a non-supported function in the SQL I'm porting, it's quick/easy to just replace it with one of my own. The biggest drawback I've found to the custom functions is the fact that they are (obviously) not available to any of the 3rd party tools I use to view/browse my raw database files with. In that case, the unknown function calls just generate errors. [... several suggestions for emulating an INT function...] Thanks for the suggestions. You've made some quite inventive attempts there... ;^) Since I've already provided my own INT function, I'm beyond that issue right now. Ultimately, I should probably go back and rewrite my queries to use CAST as DRH mentioned. Thanks, Jeff - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite core function question
Hi Jeff, I've encountered some functions that apparently aren't supported by SQLite So have I, such as replacing occurrences of an inner string. so I've created my own I've yet to figure out/try that. Is there a library somewhere of prebuilt functions we can add? Is there and mechanism for standardizing added functions so that databases used in one system are more likely to work on another, because the same functions are there? Also, several of my queries have a basic int() wrapper, that also seems to be unsupported. You could use: SELECT ROUND(x-0.499); or better yet, I expected this to work, using the modulo operator %: SELECT x - x % 1; But it just returns zero. Further testing indicates that % ignores decimal parts of the operands. So this seems to work: SELECT x % 1e100; As long as x is less than 1e100. Tom - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite core function question
From: <[EMAIL PROTECTED]> I'm not sure what "int()" does. Maybe you are looking for round(). Or perhaps cast(expr AS int) will serve your needs. Sorry, I should have been clearer. INT just forces the result to be an integer. So, your "cast" example is probably what I need. Thanks for the quick response. Jeff - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] sqlite core function question
"Jeff Godfrey" <[EMAIL PROTECTED]> wrote: > I'm currently converting some Access tables/views to SQLite. > I've encountered some functions that apparently aren't > supported by SQLite, so I've created my own (a power function > and an "IIF" function). Also, several of my queries have a > basic int() wrapper, that also seems to be unsupported. Like > the others, I've just added my own, but I wonder if I'm missing > something. The "expression" page doesn't seem to document > an "int" function, but I wonder if there is some other equivalent? > I'm not sure what "int()" does. Maybe you are looking for round(). Or perhaps cast(expr AS int) will serve your needs. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] sqlite core function question
I'm currently converting some Access tables/views to SQLite. I've encountered some functions that apparently aren't supported by SQLite, so I've created my own (a power function and an "IIF" function). Also, several of my queries have a basic int() wrapper, that also seems to be unsupported. Like the others, I've just added my own, but I wonder if I'm missing something. The "expression" page doesn't seem to document an "int" function, but I wonder if there is some other equivalent? Thanks, Jeff