SQLIte text type insert

  1. 4 months ago

    Joel_Eisenstat

    Mar 6 User since 2016

    An error keeps coming up for a TEXT field when there is a space between characters when trying to insert into an In-Memory db.
    I am not sure if this normal behaviour.

  2. marco

    Mar 6 Administrator User since 2016

    Can you please post an example?

  3. Joel_Eisenstat

    Mar 6 User since 2016

    var sql = "INSERT INTO rows (code,description,tooth,surface,amount,provider) VALUES ($$\(codeText.text)$$,$$\(descriptionText.text)$$,$$\(toothText.text)$$,$$\(surfaceText.text)$$,$$\(amountText.text)$$,$$\(providerText.text)$$)";
    SQLiteDatabase1.execute(sql);
    Console.write("\(SQLiteDatabase1.errorMessage)");

    if descriptionText.text = "oral" , no error message while " oral exam" produces an error

  4. marco

    Mar 6 Administrator User since 2016

    $$ is a PostgreSQL specific escaping sequence. For sqlite replace $$ with ' or use a DatabaseRecord object to abstract the long sql sequences and escaping.

  5. Joel_Eisenstat

    Mar 6 User since 2016

    Actually didn't use the $$ initially , was part of testing despairation,
    var sql = "INSERT INTO rows (code,description,tooth,surface,amount,provider) VALUES (\(codeText.text),\(descriptionText.text),\(toothText.text),\(surfaceText.text),\(amountText.text),\(providerText.text))";
    was the original code but adding '' fixed it .
    Thanks

or Sign Up to reply!