There are the patch: 

/***************************************************************/ 
Index: func.c 
=================================================================== 
--- func.c (revision 264) 
+++ func.c (working copy) 
@@ -117,6 +117,65 @@ 
} 

/* 
+** Implementation of the strpos() function 
+*/ 
+static void strposFunc( 
+ sqlite3_context *context, 
+ int argc, 
+ sqlite3_value **argv 
+){ 
+ const char *z; 
+ const char *z1; 
+ const char *z2; 
+ int len; 
+ int len1; 
+ int pos; 
+ int pass; 
+ 
+ assert( argc==2 || argc==3 ); 
+ if( sqlite3_value_type(argv[1]) == SQLITE_NULL 
+ || (argc==3 && sqlite3_value_type(argv[2]) != SQLITE_INTEGER) 
+ ){ 
+ return; 
+ } 
+ 
+ z = (char*)sqlite3_value_text(argv[0]); 
+ if (z == NULL) return; 
+ 
+ z1 = (char*)sqlite3_value_text(argv[1]); 
+ if (z1 == NULL) return; 
+ 
+ if (argc>=3) { 
+ pos = sqlite3_value_int64(argv[2]); 
+ if (pos == 0) return; 
+ } else pos = 1; 
+ 
+ if (pos < 0) { 
+ pass = -1; 
+ z2 = z + strlen(z) - 1; 
+ } else { 
+ pass = 1; 
+ z2 = z; 
+ } 
+ 
+ len = strlen(z); 
+ len1 = strlen(z1); 
+ do { 
+ if (strncmp(z2, z1, len1) == 0) { 
+ pos -= pass; 
+ if (pos == 0) break; 
+ } 
+ z2 += pass; 
+ } while ((z2 >= z) && (z2 < (z + len))); 
+ 
+ if (pos == 0) { 
+ sqlite3_result_int64(context, (int)(z2 - z) + 1); 
+ } else { 
+ sqlite3_result_int64(context, 0); 
+ } 
+} 
+ 
+/* 
** Implementation of the abs() function. 
** 
** IMP: R-23979-26855 The abs(X) function returns the absolute value of 
@@ -1527,6 +1586,8 @@ 
AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ), 
FUNCTION(typeof, 1, 0, 0, typeofFunc ), 
FUNCTION(length, 1, 0, 0, lengthFunc ), 
+ FUNCTION(strpos, 2, 0, 0, strposFunc ), 
+ FUNCTION(strpos, 3, 0, 0, strposFunc ), 
FUNCTION(substr, 2, 0, 0, substrFunc ), 
FUNCTION(substr, 3, 0, 0, substrFunc ), 
FUNCTION(abs, 1, 0, 0, absFunc ), 

/***************************************************************/ 


----- Mensagem original ----- 
De: "Israel Lins Albuquerque" <israel...@polibrasnet.com.br> 
Para: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> 
Enviadas: Quarta-feira, 17 de Março de 2010 12:08:56 
Assunto: Re: [sqlite] Why we don't have strpos function? 

I forgot attach... 

This are based in the current release 3.6.23. 

-- 

Atenciosamente, 

Israel Lins Albuquerque 
Desenvolvimento 
Polibrás Brasil Software Ltda. 



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


-- 

Atenciosamente, 

Israel Lins Albuquerque 
Desenvolvimento 
Polibrás Brasil Software Ltda. 


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

Reply via email to