Re: [sqlite] User function in WHERE clause
O.K. This is what I need. Thanks -- View this message in context: http://www.nabble.com/User-function-in-WHERE-clause-tf2009603.html#a5543377 Sent from the SQLite forum at Nabble.com.
Re: [sqlite] User function in WHERE clause
On 7/28/06, Stan <[EMAIL PROTECTED]> wrote: But there are my problems: 1) Return value xFunc is void? I have to return integer. 2) Where are described parameters in xFunc? E.g. what is it "sqlite3_context"? Stan, Check out section 2.3 User defined funcion s on this page http://www.sqlite.org/capi3.html HTH Dennis Cote
Re: [sqlite] User function in WHERE clause
Thanks for answer. Yes, I have read this many times, but... ...I'm dumb maybe. I understand first 5 parameters in the "sqlite3_create_function". xStep and xFinal will be NULL. But there are my problems: 1) Return value xFunc is void? I have to return integer. 2) Where are described parameters in xFunc? E.g. what is it "sqlite3_context"? Thanks for your time. Stan -- View this message in context: http://www.nabble.com/User-function-in-WHERE-clause-tf2009603.html#a5542532 Sent from the SQLite forum at Nabble.com.
Re: [sqlite] User function in WHERE clause
Thanks for tip. I'm happy to see it's possible. Alas, I'm rather confused. I have read documentation, but I'm not sure what parameters to use and what return value for WHERE clause. Can you be so kind and show me a skeleton (C++) function for this: SELECT * FROM Table WHERE MYFUNC(ColumnName, IntValue) ? And how to include MYFUNC to SQLite ? ... you see - troubles of a beginner :-). Thanks Stan -- View this message in context: http://www.nabble.com/User-function-in-WHERE-clause-tf2009603.html#a5535131 Sent from the SQLite forum at Nabble.com.
RE: [sqlite] User function in WHERE clause
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 27, 2006 8:33 AM > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] User function in WHERE clause > > "param MYFUNCTION Name" is equivalent to > "MYFUNCTION(Name, param)" onoly if MYFUNCTION > is one of: > > LIKE GLOB REGEXP MATCH > > Only LIKE and GLOB are defined by default. MATCH is > not in 3.3.6, but is in the source tree. > > Note that you can use sqlite3_create_function() to > replace the build-in LIKE or GLOB function to do > whatever it is you want. REGEXP is undefined, so you > can define it to do whatever you need, though as you > can probably guess, it is intended for regular > expression matching. Ah that explains things a bit. I just happened to have overridden REGEXP without realizing it was pre-defined to allow you to call it that way. Am I mistaken, or did you recently check-in a patch that fixes the parameters so that "a REGEX b" is the same as "REGEX(a,b)" ? Robert
Re: [sqlite] User function in WHERE clause
"Robert Simpson" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: Igor Tandetnik [mailto:[EMAIL PROTECTED] > > Sent: Thursday, July 27, 2006 7:48 AM > > To: SQLite > > Subject: [sqlite] Re: User function in WHERE clause > > > > Stan <[EMAIL PROTECTED]> wrote: > > > is there a way to create user function similar to LIKE? > > > I'd like to use my function in clause WHERE. E.g. this selection: > > > SELECT * FROM Table WHERE Name MYFUNCTION param > > > Param is integer. > > > > Not like this, but you can create a function and use it this way: > > > > SELECT * FROM Table WHERE MYFUNCTION(Name, param) > > Actually with a userdef function, > > SELECT * FROM Table WHERE MYFUNCTION(Name, param) > > is identical to: > > SELECT * FROM Table WHERE param MYFUNCTION Name > "param MYFUNCTION Name" is equivalent to "MYFUNCTION(Name, param)" onoly if MYFUNCTION is one of: LIKE GLOB REGEXP MATCH Only LIKE and GLOB are defined by default. MATCH is not in 3.3.6, but is in the source tree. Note that you can use sqlite3_create_function() to replace the build-in LIKE or GLOB function to do whatever it is you want. REGEXP is undefined, so you can define it to do whatever you need, though as you can probably guess, it is intended for regular expression matching. -- D. Richard Hipp <[EMAIL PROTECTED]>
Re: [sqlite] User function in WHERE clause
On 7/27/06, Stan <[EMAIL PROTECTED]> wrote: Hi, is there a way to create user function similar to LIKE? I'd like to use my function in clause WHERE. E.g. this selection: SELECT * FROM Table WHERE Name MYFUNCTION param Param is integer. http://sqlite.org/capi3ref.html#sqlite3_create_function -- SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com