More Help
- Posted by GeorgeWalters Aug 11, 2008
- 916 views
I"m trying to put escape char in front of ",',\, ascii 0 that are in a binary file (PDF in this case). I then want to put the sequence into a mysql blob column but get a syntax error from mysql. Here is the mysql doc
If you want to insert binary data into a string column (such as a BLOB), the following characters must be represented by escape sequences:
NUL NUL byte (ASCII 0). Represent this character by `\0' (a backslash followed by an ASCII `0' character).
\ Backslash (ASCII 92). Represent this character by `
'.
' Single quote (ASCII 39). Represent this character by `\''.
" Double quote (ASCII 34). Represent this character by `\"'.
When writing application programs, any string that might contain any of these special characters must be properly escaped before the string is used as a data value in an SQL statement that is sent to the MySQL server.
Here's the code. Do you see a problem?
tmpString={} for j = 1 to len (outRecord[i]) do if find(outRecord[i][j], {92,39,34,0}) then --\,',", ascii 0 tmpString &= 92 & outRecord[i][j] else tmpString &= outRecord[i][j] end if end for if fileControl[t][i] = 0 then tmp &= ", \"" & tmpString & "\"" else tmp &= ", " & tmpString end if