Dennis Cote wrote:

> You can use the replace() function to strip the newlines from your 
> strings. You could replace the newlines with empty strings or with a 
> single space. The trick is entering the newlines. You can enter them 
> directly in an sql script file.
> 
> select replace(some_column, '
> ',' ') from a_table;
> 
> Or you can use a cast and enter the expected newline characters for your 
> system (i.e. Windows is 0d0a, *nix is 0a, etc).
> 
> select replace(some_column, cast(x'0d0a' as text), ' ') from table
> 
> Then the columns can be truncated using the substr() function as you 
> suggest. The resulting strings should fit in your grid.
Thanks Dennis! Works great. This is what I came up with:

NOTES="$(cmd2db ".mode column" ".width 3 80" ".headers off" "SELECT 
id,replace(substr(note,1,80),cast(x'0a' as text),' ') FROM notes WHERE 
type LIKE '%$TYPE%'$SUBTYPE LIMIT $LMT;")"

echo    "$NOTES"|sed -e 's/     / /g'   

I'm using sed to replace tabs with a space.I suppose I could use another 
  replace-cast in the SQL. cmd2db is a really simple function to pass 
multiple commands to sqlite. I'm sure there is a better way, but this works.

NOTES is a table in my personal information manager to store random text.

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

Reply via email to