Android Question [CLOSED] SQLite: inserting return characters

TyneBridges

Member
Licensed User
Longtime User
In order to ensure a "clean" import I've removed return characters (line feeds) from my database text entries by replacing them with an unused character. I'm now trying to put them back. The line

OurCursor = G.SQL1.ExecQuery("Update DEntries set Entry = replace(Entry, '}', char(10)) where Entry like '%}%'")

compiles, but gives SQLiteException
no such function: char (code1)

at run time.

Changing the replace string to '\10' or '\\10' will run, but this just inserts those literal characters - that is, text punctuated by \10 like this\10, not the line feeds that I want. ("Entry" is a field of type Text in my SQLite database.)

Can this be done, or will SQLite not accept these characters within text fields?

Thanks for any help.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

TyneBridges

Member
Licensed User
Longtime User
Thanks for the suggestion but I'm afraid it doesn't work for me - if I use the line above with the 'a' removed from 'char' I still get a runtime error "No such function: chr (code 1)".
 
Upvote 0

TyneBridges

Member
Licensed User
Longtime User
I've also tried the following. This also compiles but gives a similar runtime error

Dim R As String: R = Chr(10)
OurCursor = G.SQL1.ExecQuery("Update DEntries set Entry = replace(Entry, '}'," & R & ") where Entry like '%}%'")
 
Upvote 0

cimperia

Active Member
Licensed User
Longtime User
The following will replace the '}' with new line feeds.

B4X:
  Update DEntries set Entry = replace(Entry, '}', X'0A') where Entry like '%}%';
 
Last edited:
Upvote 0

TyneBridges

Member
Licensed User
Longtime User
Thanks Cimperia! That seems to have solved my problem. Brilliant.
 
Upvote 0
Top