Igor Tandetnik wrote:
> 
> 
> That function can also check the type of its parameter and return it
> unchanged if it's not a string. Or, you could do that in SQL:
> 
> select (case when typeof(field) = 'text' then reverse(field) else field
> end)
> from myTable;
> 
> 


I tried the case function that was recommended, but that seems to recognise
everything in the column as text except when it encounters a NULL.  I
changed the column type to varchar, but that made no difference.  What am I
missing here?  

select (case when typeof (translit) = 'text' then translit else "@" end) 
from otpfinal;

This was a test to see if it would recognise numbers and replace them with
an @.  It only replaced NULL fields.


By the way, I was able to (after much searching) find a way that I could
reverse text in SQLITE, this will reverse strings upto 30 characters long as
the column "reversed"

SELECT translit,
    SUBSTR(translit,-1,1)||
    SUBSTR(translit,-2,1)||
    SUBSTR(translit,-3,1)||
    SUBSTR(translit,-4,1)||
    SUBSTR(translit,-5,1)||
    SUBSTR(translit,-6,1)||
    SUBSTR(translit,-7,1)||
    SUBSTR(translit,-8,1)||
    SUBSTR(translit,-9,1)||
    SUBSTR(translit,-10,1)||
    SUBSTR(translit,-11,1)||
    SUBSTR(translit,-12,1)||
    SUBSTR(translit,-13,1)||
    SUBSTR(translit,-14,1)||
    SUBSTR(translit,-15,1)||
    SUBSTR(translit,-16,1)||
    SUBSTR(translit,-17,1)||
    SUBSTR(translit,-18,1)||
    SUBSTR(translit,-19,1)||
    SUBSTR(translit,-20,1)|| 
    SUBSTR(translit,-21,1)||
    SUBSTR(translit,-22,1)||
    SUBSTR(translit,-23,1)||
    SUBSTR(translit,-24,1)||
    SUBSTR(translit,-25,1)||
    SUBSTR(translit,-26,1)||
    SUBSTR(translit,-27,1)||
    SUBSTR(translit,-28,1)||
    SUBSTR(translit,-29,1)||
    SUBSTR(translit,-30,1) 'reversed' 
from otpfinal4;

 

-- 
View this message in context: 
http://old.nabble.com/Reversing-Text-not-Numbers-tp32906645p32945134.html
Sent from the SQLite mailing list archive at Nabble.com.

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

Reply via email to