EASY.SQL.2025.09.01 (A lot of new stuff!)

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
srvet_claudio
Posts: 2223
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post by srvet_claudio »

Hi Marek,
Have you tried saving the image directly as a BLOB data?
Like this:

CREATE TABLE Image (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
imageData LONGBLOB
);
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mol
Posts: 3789
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post by mol »

I don't know how to transfer binary data to a postgresql server directly
User avatar
serge_girard
Posts: 3333
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post by serge_girard »

Marek, your code isn't working?
Looks good to me:

Code: Select all

cContent := hb_Base64Encode( hb_memoread("place.jpg") )
cSQL := "INSERT INTO images (Zawartosc) VALUES (decode('" + cContent + "','base64' ) ) RETURNING Image_ID"
aTmp := pgSelectQuery(oServerMaster,cSQL, .t.)
if empty(aTmp)
	MsgDebug("Error!")
	return
endif

// retriving file from server
nId := aTmp[1,1]
	
cSQL := "SELECT encode(Zawartosc::ByteA, 'base64') FROM  images WHERE image_id = " + hb_ntos(nId)
aTmp := pgSelectQuery(oServerMaster,cSQL, .f.)
	
if !empty(aTmp)
	hb_memowrit('Odpowiedz.jpg', hb_Base64Decode(aTmp[1][1]))
	execute file 'odpowiedz.jpg'
endif

There's nothing you can do that can't be done...
Post Reply