Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Location
    New Delhi - India
    Posts
    22

    Unanswered: Storing NULL Character in SQLite

    Hi,

    I am trying to store a value containing NULL character and escape sequences in a char column in SQLite. How can store and retrieve it correclty.
    I have the below insert query:

    snprintf(SqlStr,size, "INSERT INTO %s (AttrName, AttrEnum, AttrType, AttrValue, eadWrite, Entity_id) VALUES('%s', %d, %d, '%s', %d, %d);", tbl_name, db[i]>attr_name, db[i]->attr_num, db[i]->attr_type, db[i]->attr_value, db[i]->atr_src, entity_id);

    attr_value contains "AB34\04FE".

    It may contain other escape sequence at any index. How can I handle it using SQLite C library.

    Thanks
    Manik Sidana

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    There is no ASCII NUL value in the string that you posted, so I'm not sure what is the problem.

    SQL-Lite can be complied a number of different ways, some of which are tolerant of NUL values and some of which very decidedly aren't tolerant of NUL values. If I was not sure that every SQL-Lite implementation that your application can/will use is tolerant of NUL values, then I would modify your code to backslash quote every suspect string for storage and dequote them on retrieval.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •