Hello! I'm using the function from SQLite tests:
static void counterFunc( sqlite3_context *pCtx, /* Function context */ int nArg, /* Number of function arguments */ sqlite3_value **argv /* Values for all function arguments */ ){ int i; int *pCounter; pCounter = (int*)sqlite3_get_auxdata(pCtx, 0); if( pCounter==0 ){ pCounter = sqlite3_malloc( sizeof(*pCounter) ); if( pCounter==0 ){ sqlite3_result_error_nomem(pCtx); return; } *pCounter = sqlite3_value_int(argv[0]); sqlite3_set_auxdata(pCtx, 0, pCounter, sqlite3_free); }else{ ++*pCounter; } sqlite3_result_int(pCtx, *pCounter); } But the result is strange: sqlite> select value=0,counter(0),counter(value=0) from state; 0|0|0 0|1|0 0|2|0 0|3|0 0|4|0 0|5|0 0|6|0 0|7|0 0|8|0 0|9|0 0|10|0 0|11|0 0|12|0 Of course I need to get the result of counter(value==0) equal to counter(0). The result of "value=0" is always 0 and so counter(value=0) may be identical to counter(0). P.S. I want build function similar to linux "uniq" utility: select value from state where uniq(value)=1; This can emulate "distinct on" clause too. Best regards, Alexey Pechnikov. http://pechnikov.tel/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users