[Gambas-user] Gambas blob behavior: Problems with retreiving a binary file stored in a database

Benoît Minisini gambas at ...1...
Fri Jul 19 10:43:34 CEST 2013


Le 18/07/2013 19:28, PICCORO McKAY Lenz a écrit :
>
>     Can you send me the SQL schema of the table that receives your blob?
>     Did you create that schema from the Gambas IDE or from the outside?
>
> sql schema are not need, u can try CREATE TABLE in sqlite or postgres
> etc etc and made a only blob field..
>
> the problem its not really make FILE.Save(data,path)
>
> the problem are raised when i change the behavior of that sql for search
> another data blob..
>
> if i always search for same data, always work..
>
> so then the problem only can reproduce if u have multiple files stored
> in the table, see that:
>
> CREATE TABLE sysasis_registro (
> cod_ficha VARCHAR(20) NOT NULL , -- ficha/cedula/id del trabajador
> hex_huelladactilar BLOB NOT NULL , -- huella dactilar tomada
> PRIMARY KEY (cod_ficha) )
>
> so then if i search and save always for same "cod_ficha" , the File.Save
> always work.. but when i search for another different "cod_ficha" data
> when saved to path are corrupted or 0k
>
> i solved with a hex dump feature made by misa3l.. so search for problem
> and seem that DBMS stored scaped the blob data in field.. its hard to
> explaint for me.. but seems important for improved the gambas languaje & ide
>
>
>     --
>     Benoît Minisini
>
>

I tested with a mysql table created with Gambas classes having one blob 
field. I fill many records with the file provided by you, and I could 
retrieve the blobs as expected.

Maybe your problem comes from the fact that "BLOB" is not a real field 
type in mysql, but a synonymous of "TEXT". In other words, there is no 
blobs in mysql (or no text field if you prefer).

To make the difference, I took the following decision in the mysql 
gambas driver:

- If the maximum length of the field is < 0 or >= 16777216, or if the 
mysql field datatype is "LONGBLOB" or "LONGTEXT", then it is a blob, and 
so a Blob in Gambas.

- Otherwise, it is a text field, and so a String in Gambas.

Can you try to use "LONGBLOB" instead of "BLOB" and tell me it works 
better for you?

Regards,

-- 
Benoît Minisini




More information about the User mailing list