Android Question [CLOSED] SQLite: inserting return characters

Discussion in 'Android Questions' started by TyneBridges, Jul 23, 2015.

  1. TyneBridges

    TyneBridges Member Licensed 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.
     
  2. DonManfred

    DonManfred Expert Licensed User

    char(10) creates an array of char with 10 items.

    Use chr(10) to get \10
     
    lemonisdead likes this.
  3. TyneBridges

    TyneBridges Member Licensed 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)".
     
  4. TyneBridges

    TyneBridges Member Licensed 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 '%}%'")
     
  5. cimperia

    cimperia Active Member Licensed User

    The following will replace the '}' with new line feeds.

    Code:
    Update DEntries set Entry = replace(Entry, '}', X'0A') where Entry like '%}%';
     
    Last edited: Jul 23, 2015
  6. TyneBridges

    TyneBridges Member Licensed User

    Thanks Cimperia! That seems to have solved my problem. Brilliant.
     
Loading...