[Gambas-user] escape a picture

Benoît Minisini gambas at ...1...
Wed Nov 25 03:14:09 CET 2009


> Benoît Minisini a écrit :
> >> Benoît Minisini a écrit :
> >>>> Hi,
> >>>>
> >>>> How can I escape a picture in order to insert it into a BYTEA
> >>>> postgresql data field?
> >>>
> >>> Normally, if the postgresql field datatype is BYTEA, the gb.db
> >>> component will see it as a blob.
> >>>
> >>> Let's suppose the field name is "Picture". You will do:
> >>>
> >>> MyResult!Picture = File.Load("/path/to/picture/file")
> >>>
> >>> Is it what you need?
> >>
> >> NO, I need the opposite:
> >> sqlQry = "SELECT MyTable_ins(MyPicture);
> >>
> >> where MyTable_ins(TEXT) is a stored PLPGSQL procedure that do
> >> an indirect insert into myschema.mytable
> >
> > OK. So MyPicture must be a string including quoted binary data?
> >
> > Alas there is no public access to the internal driver function that
> > quotes binary data for a blob. Do you want me to add it in Gambas 3?
> > Something like DB.QuoteBlob()?
> 
> What would also be nice would be direct conversions (ie: from String
> to Picture and reverse)
> 

Maybe, but this is a lot of work for very little gain: using a temporary file 
to store the picture is faster than reading/writing the data in the database, 
as the binary data must be quoted in a string (SQL is so stupid!).

Regards,

-- 
Benoît Minisini




More information about the User mailing list