On 9/10/08 11:11 AM, "Dennis Cote" <[EMAIL PROTECTED]> wrote:
> Josh Millstein wrote:
>> On 9/9/08 11:46 AM, "Igor Tandetnik" <[EMAIL PROTECTED]> wrote:
>>> Josh Millstein <[EMAIL PROTECTED]>
>>> wrote:
>>>> Is there anyway to perform a trim to everything that is entered into
>>>> a table instead of trimming before I put data in?
>>>
>>> update mytable set myfield=trim(myfield);
>>>
>>
>> Yeah, but can you do that automatically on each insert into the db. Trim
>> the whitespace, that is?>
>
> Yes. Simply do these updates in triggers. You will need to add two
> triggers, one that executes after each insert, and one that executes
> after each update.
>
> create trigger mytab_in after insert on mytable
> begin
> update mytable
> set myfield = trim(myfield)
> where rowid = new.rowid;
> end;
>
> create trigger mytab_in after update of myfield on mytable
> begin
> update mytable
> set myfield = trim(myfield)
> where rowid = new.rowid;
> end;
>
> Now your application can insert untrimmed data, but the database will
> only store trimmed data, and therefore you will only ever retrieve
> trimmed data.
>
> HTH
> Dennis Cote
Awesome, thank you for the info.
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
--
[EMAIL PROTECTED]
785-832-9154
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users