passing binary data to MySQL BLOB field

Björnke von Gierke bvg at mac.com
Tue Mar 5 07:01:12 CST 2013


Not sure why it won't work for you, but it seems that your first try had some typo or otherwise wrong code. Your copy/paste has code missing so it's hard to say what the problem is. The second error looks like you forgot some closing brackets or quotation marks, again it's hard to tell due to lack of full code.  One thing to note is that all variables used for substitution have to exist, unlike all other places in LC, where missing variables are assumed to be empty. Here's an example that probably should work, but is untested:

--assuming revopendatabase works as expected
put "blah" into fileNameVar
put "pretend this is binary" into binaryObjectVar
revexecuteSQL MyDatabaseID, "INSERT INTO Assets ('FileName', 'File') VALUES(:1,:2)", "fileNameVar", "*bbinaryObjectVar"

On 05.03.2013, at 02:26, Sieg Lindstrom wrote:

> 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
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


-- 

Use an alternative Dictionary viewer:
http://bjoernke.com/bvgdocu/

Chat with other RunRev developers:
http://bjoernke.com/chatrev/





More information about the use-livecode mailing list