Re: [sqlite] last occurrence of /*
It is possible using ‘with recursive’. The following is ugly and inefficient but might give you some ideas. with recursive cte (x,str) as (select 0,?1 union select x-1,substr(?1,x-1) from cte limit length(?1)) select str from cte where substr(str,1,2)='/*' order by -x limit 1; From: sqlite-users on behalf of Bart Smissaert Sent: Friday, December 6, 2019 11:59:06 PM To: SQLite mailing list Subject: Re: [sqlite] last occurrence of /* I think it can be done. Just dealing with the forward slash. RBS On Fri, Dec 6, 2019 at 11:49 PM Simon Slavin wrote: > On 6 Dec 2019, at 11:00pm, Bart Smissaert > wrote: > > > How do I select the part of this statement starting with the last /* ? > > Not in SQLite. Do it in your code, or write your own function to do it > and load this function into SQLite. > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
On 6 Dec 2019, at 11:59pm, Bart Smissaert wrote: > I think it can be done. > Just dealing with the forward slash. Then use replace(X,Y,Z) to replace '/*' with something else before you do whatever you were intending to do. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
I think it can be done. Just dealing with the forward slash. RBS On Fri, Dec 6, 2019 at 11:49 PM Simon Slavin wrote: > On 6 Dec 2019, at 11:00pm, Bart Smissaert > wrote: > > > How do I select the part of this statement starting with the last /* ? > > Not in SQLite. Do it in your code, or write your own function to do it > and load this function into SQLite. > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
I can do it in code. This is B4A on Android phone. For that reason can't do UDF's or extensions. This postcode thing was just a simple example, not to do with comment issue. RBS On Fri, Dec 6, 2019 at 11:48 PM Scott Robison wrote: > On Fri, Dec 6, 2019, 4:31 PM Bart Smissaert > wrote: > > > I know I can do something like this: > > > > select replace(postcode, rtrim(postcode, replace(postcode, ' ', '')), '') > > from addresses > > > > which will get the part of the postcode starting with the space. > > Problem however is how to deal with the forward slash. > > > > Do you have to do this in SQLite itself? Can you load an extension that > provides regex? How did you go from comment strings to postcodes? > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
On 6 Dec 2019, at 11:00pm, Bart Smissaert wrote: > How do I select the part of this statement starting with the last /* ? Not in SQLite. Do it in your code, or write your own function to do it and load this function into SQLite. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
On Fri, Dec 6, 2019, 4:31 PM Bart Smissaert wrote: > I know I can do something like this: > > select replace(postcode, rtrim(postcode, replace(postcode, ' ', '')), '') > from addresses > > which will get the part of the postcode starting with the space. > Problem however is how to deal with the forward slash. > Do you have to do this in SQLite itself? Can you load an extension that provides regex? How did you go from comment strings to postcodes? ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
I know I can do something like this: select replace(postcode, rtrim(postcode, replace(postcode, ' ', '')), '') from addresses which will get the part of the postcode starting with the space. Problem however is how to deal with the forward slash. RBS On Fri, Dec 6, 2019 at 11:09 PM Scott Robison wrote: > On Fri, Dec 6, 2019, 4:00 PM Bart Smissaert > wrote: > > > Have table with SQL statements and these statements may have comments, > > starting with /* > > How do I select the part of this statement starting with the last /* ? > > So if the statement is: > > select field1 /*comment 1 */ from table1 /*comment 2*/ > > I would like to get: > > /*comment 2*/ > > > Is there more format to the comment than just plain text? > > My senior project was a SQLite helper that would read a bunch of statements > from a sql script and create classes to automate the boilerplate code and > ensure they were prepareable. To accomplish this I needed some new syntax > that wouldn't interfere with SQLite, so I embedded it in comments, but they > had to conform to a simple structure so that I could find them via regex. > > Perhaps, if it is only the last comment you care about, you could use a > regex. I'm on a phone right now and don't want to try to type in valid > regex strings, but that would be useful I could help with it when I'm near > a real keyboard. > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] last occurrence of /*
On Fri, Dec 6, 2019, 4:00 PM Bart Smissaert wrote: > Have table with SQL statements and these statements may have comments, > starting with /* > How do I select the part of this statement starting with the last /* ? > So if the statement is: > select field1 /*comment 1 */ from table1 /*comment 2*/ > I would like to get: > /*comment 2*/ Is there more format to the comment than just plain text? My senior project was a SQLite helper that would read a bunch of statements from a sql script and create classes to automate the boilerplate code and ensure they were prepareable. To accomplish this I needed some new syntax that wouldn't interfere with SQLite, so I embedded it in comments, but they had to conform to a simple structure so that I could find them via regex. Perhaps, if it is only the last comment you care about, you could use a regex. I'm on a phone right now and don't want to try to type in valid regex strings, but that would be useful I could help with it when I'm near a real keyboard. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users