Simon Slavin <slav...@bigfraud.org> wrote:
> On 7 Feb 2011, at 8:38am, Harish CS wrote:
> 
>> Table T has two varchar columns A and B. UI allows entering values into
>> column A only.
>> On insert/update of records, I need to take out the value of A, filter out
>> anything other than '0' to '9', '*', '#', '+' 'p', 'w' characters and copy
>> it to column B. Is it possible to write a trigger to achieve this? If yes
>> please give me a sample. (Also, if column B is in another table, is it
>> possible?)
> 
> I don't think you need a trigger.  You might find the 'trim(X,Y)' function

trim just removes leading and trailing characters. It won't help with, say, 
'1x2'. The closest you could come using built-in functions is something like

replace(replace(...(replace(new.A, 'a', ''), 'b', ''), 'c', '')...)

but that's impractical.

Personally, I'd do the transformation in the application code. Barring that, a 
custom function (like strfilter mentioned in this thread) is in order.
-- 
Igor Tandetnik

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

Reply via email to