Re: [sqlite] Changing row separator to null when accessing sqlite frombash script

2011-07-19 Thread Igor Tandetnik
Richard Taubo  wrote:
> I have a bash script like this:
> 
> #!/bin/bash
> OIFS=$IFS
> IFS=$'\n';
> sql_command=`sqlite3 -noheader /My/Path/To/DB/ex1 "select one from tbl1 WHERE 
> one LIKE '%this%';"`
> for i in $sql_command
> do
>echo "$i"
> done
> IFS=$OIFS;
> 
> 
> Since the column "one" consists of text with new lines in them, I am 
> investigating of it is possible to
> set a row seperator (if that exists in sqlite) to null so I won't have any 
> problems with text splitting up
> incorectly.

Try changing your query to something like

select one || x'00' from tbl1 WHERE one LIKE '%this%';

You can add any other separator this way. Note that it will be in addition to, 
not in place of, the line feed character.
-- 
Igor Tandetnik

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


Re: [sqlite] Changing row separator to null when accessing sqlite frombash script

2011-07-19 Thread Roger Andersson
  On 07/19/11 01:41 PM, Igor Tandetnik wrote:
> Richard Taubo  wrote:
>> I have a bash script like this:
>>
>> #!/bin/bash
>> OIFS=$IFS
>> IFS=$'\n';
>> sql_command=`sqlite3 -noheader /My/Path/To/DB/ex1 "select one from tbl1 
>> WHERE one LIKE '%this%';"`
>> for i in $sql_command
>> do
>> echo "$i"
>> done
>> IFS=$OIFS;
>>
>>
>> Since the column "one" consists of text with new lines in them, I am 
>> investigating of it is possible to
>> set a row seperator (if that exists in sqlite) to null so I won't have any 
>> problems with text splitting up
>> incorectly.
> Try changing your query to something like
>
> select one || x'00' from tbl1 WHERE one LIKE '%this%';
>
> You can add any other separator this way. Note that it will be in addition 
> to, not in place of, the line feed character.
Maybe something like
select replace(one,x'0a','') from tbl1 WHERE one LIKE '%this%';


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