troubleshooting Question

MySQL Search syntax for Binary Strings from VFP

Avatar of Mike Jacobs
Mike JacobsFlag for United Kingdom of Great Britain and Northern Ireland asked on
MySQL Server
4 Comments1 Solution188 ViewsLast Modified:
Up to now in my Mysql searches, I've only performed searches for BIGINTs and INTs which behave as I expect. (with the minor quibble I raised a few days ago about why BIGINTs appear as string data not numeric)

Now I'm trying to perform a search for a binary string and I cannot get the syntax right

Sample Code

TARGHASH=HASH_SALTED
&& An SHA256 32 Byte value stored, locally, in a 32 byte VFP CHAR(BINARY) Field and remotely  in a 32 byte Mysql Varbinary column

I prepare a string to encode the SQSTRING I will use in the select statement thus:
success=SQLPREPARE(HND,SQSTRING,'ROWFOUND')

IF NOT CHECK_EXECUTE(SUCCESS,HND)  && a function which checks the syntax and displays any errors or goes on to execute it
      CANCEL
ENDIF
SUSPEND

with and without
CURSORSETPROP("MapBinary",.t.,0)

I have tried the following versions of SQSTRING :

SQSTRING="SELECT HASH_SALTED,ROWNUM FROM HASH_CHAIN WHERE HASH_SALTED="+TARGHASH
*anticipated this would work because the VFP field is CHAR(BINARY) and to the human eye the raw data in the vfp table looks identical to the raw data visible in the Mysql column

SQSTRING="SELECT HASH_SALTED,ROWNUM FROM HASH_CHAIN WHERE HASH_SALTED="+ENCODE(TARGHASH,'HEX')
*ENCODE IS A CALL TO A CHILCRYPT LIBRARY WHICH CONVERTS THE STRING TO HEX

SQSTRING="SELECT HASH_SALTED,ROWNUM FROM HASH_CHAIN WHERE HASH_SALTED=BINARY"+TARGHASH

SQSTRING="SELECT HASH_SALTED,ROWNUM FROM HASH_CHAIN WHERE HASH_SALTED=CONVERT("+TARGHASH+",BINARY)"

all are rejected with the standard mysql error

eg: "Connectivity error: .... check the manual to your mysql server version for the right syntax to use near ïÆÅ9q"¥Á5ºå;?      û#õ”úC

Can someone please put me out of my misery?
ASKER CERTIFIED SOLUTION
Arana (G.P.)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros