If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Storing NULL Character in SQLite

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-19-11, 10:12
manik019 manik019 is offline
Registered User
 
Join Date: Mar 2009
Location: New Delhi - India
Posts: 22
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
Reply With Quote
  #2 (permalink)  
Old 09-19-11, 11:52
Pat Phelan Pat Phelan is online now
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,613
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On