Thanks Birgita,

I know the RPG technique you are showing.

We are preparing a proof of concept to save a blob/cblob from SQL with PHP,
Java, etc. clients. That is the reason to try it from SQL and not reinvent
the wheel.

Best regards

Javier Mora

El lun, 6 ene 2025 a las 17:06, Birgitta Hauser (<Hauser@xxxxxxxxxxxxxxx>)
escribió:

Not sure why you do not want to use RPG?
The following example generates an XML document and writes it directly
into the IFS (nothing else is needed).
You need to define a CLOB-File, and then fill the File Name
(MYXMLDOC_Name) with your IFS File Name, the Name Length (MYXMLDOC_NL) with
the length of the name (without Blanks) and finally set the Operation
(MYXMLDOC_FO) to either SQFRD (=Read), SQFCRT (create a new file), SQFOVR
(create a new file or replace a existing one) or SQFAPP (create a new file
or add the data at the end of an existing file).
The data is directly written into the IFS with the SELECT ... INTO
Statement.

DCL-S MyXMLDoc SQLTYPE(XML_CLOB_File);

Clear MyXMLDoc;
MyXMLDoc_Name = '/home/Hauser/Examples/WriteXMLStaff.xml';
MyXMLDoc_NL = %Len(%Trim(MyXMLDoc_Name));
MyXMLDoc_FO = SQFOVR; //Replace if
exists

Exec SQL
Select XmlDocument
(xmlgroup(EmployeeNo as "PersNo",
Trim(Trim (FirstName) concat ' ' concat
Trim(Name)) as "PersName",
Address as "Street",
ZipCode as "ZipCode",
City as "City"
Order By City Desc, Name
Option Row "Employee"
Root "Staff"))
into :MyXMLDoc
From LobStaff;

If SQLCODE < *Zeros;
Dsply 'Error occured';
else;
Dsply 'XML Document generated';
EndIf;

*InLR = *On;

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i
Database and Software Architect
IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
"Train people well enough so they can leave, treat them well enough so
they don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!" (Albert
Einstein)

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of datil400
Sent: Monday, 6 January 2025 14:11
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Save a BLOB only with SQL

Hello Daniel,

IFS_WRITE_BINARY is a stored procedure that cannot be called directily
from a SELECT statement, as in the case of 'get_blob_from_file'.

Will I have to create a user-defined function for this purpose?

Thanks

Javier Mora

El dom, 5 ene 2025 a las 22:07, Daniel Gross (<daniel@xxxxxxxx>) escribió:

Hi Javier,

i would try IFS_WRITE_BINARY.

->
https://www.ibm.com/docs/en/i/7.5?topic=is-ifs-write-ifs-write-binary-
ifs-write-utf8-procedures

HTH
Daniel


Am 05.01.2025 um 21:51 schrieb datil400 <datil400@xxxxxxxxx>:

Hi guys,

Is there any way to save a BLOB type in the IFS without having to
use
RPG?

To load a BLOB you can use the function 'get_blob_from_file' but I
can't find the complementary one. Does this exist?

Best regards

--
Javier Mora
https://github.com/datil400
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post
a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.

--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.


--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.