Skip to content

Instantly share code, notes, and snippets.

@MySohoWiki
Created October 26, 2022 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MySohoWiki/2ae050b78b5ee5899a7157cf8f9ddde7 to your computer and use it in GitHub Desktop.
Save MySohoWiki/2ae050b78b5ee5899a7157cf8f9ddde7 to your computer and use it in GitHub Desktop.
Use File Stream
procedure textXML;
var
fs: tfilestream;
s: string;
r: variant;
begin
//TEST table is "create table _testXML(id int identity not null primary key, data varchar(max), datXML XML)"
//
//upload xml file to server
fs:= tfilestream.create('D:\demo\delphi\Synapse https\test1\sendInvoice.xml',fmOpenRead);
try
fs.read(s, fs.size);
r:= prg.QueryValues('INSERT INTO _testXML(data,datXml) OUTPUT Inserted.ID VALUES(:1,:2)', [s,s]);
//showmessage(r);
finally
fs.free;
end;
//Get an XML from server and save to file
fs:= tfilestream.create('D:\demo\delphi\xxx.xml',fmCreate);
try
r:= prg.QueryValues('select datXML from _testXML where id=:1', r);
fs.write(r, length(r));
finally
fs.free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment