passing binary data to MySQL BLOB field

Sieg Lindstrom sl at trackandfieldnews.com
Mon Mar 4 20:26:32 EST 2013


Can anyone advise what the correct syntax should be to construct a MySQL "INSERT" query that passes variables from LiveCode when one of said variables is a binary object? I am trying to construct the statement and then use it with RevExecuteSQL. I'm particularly trying to understand the LC Dictionary note that reads, "To pass binary data in a variable in the variablesList, prepend "*b" to the variable name. The revExecuteSQL command strips the binary marker "*b" and passes it to the database as binary data, rather than text data.

Fair enough. My second variable in the query below, binaryObjectVar, is a binary object. So I try this:

INSERT INTO Assets (`FileName`, `File`) VALUES(:1,:2)", "fileNameVar", "*bbinaryObjectVar"

The result is this LC error: "compilation error at line 486 (Expression: double binary operator) near "*", char 24"

If I try the query without using "*b" MySQL chokes on the binary data in binaryObjectVar and sends the following error message:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':1,:2,:3,:4)", "test_file.pdf", %PDF-1.5%...' at line 1"

So I've tried a number of permutations for including "*b". I've tried quotes around the variable name with "*b" prepended within those quotes, "*b" prepended before the open quote, etc. In each case, MySQL still gags on the binary data.

Help! While this may sound like a misplaced MySQL syntax question, it's not. What I'm missing is how to properly prepend "*b" so LC sends the variable as binary data. ???

Thanks in advance,

Sieg Lindstrom


More information about the use-livecode mailing list