Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Are COMPRESS() / DECOMPRESS() only intended for use within a SQLA database or are the algorithms used compatible with external utilities? In other words, should I expect the output zip archive of this process to be accessible by Windows Explorer, 7zip etc:

create variable uncomp long binary;
create variable comp long binary;
set uncomp = xp_read_file('c:\temp\stuff.txt');
set comp = compress(uncomp,'zip');
call xp_write_file('c:\temp\stuff.zip',comp);

I find I can't read that file outside SQLA (nor if I use the gzip algorithm). Am I missing something obvious (wouldn't be the first time!)?

The docs say "Zip is a widely supported compression algorithm. Gzip is compatible with the gzip utility on Unix, whereas the zip algorithm is not. " I'm doing my gzip testing on Windows with 7zip, not on Linux/Unix, but other gzip archives seem to work fine.

v17.0.9.4838

asked 13 Nov '18, 09:16

Justin%20Willey's gravatar image

Justin Willey
7.6k137179249
accept rate: 20%

You certainly have noticed Mark's old response here, haven't you?

Note, I'm just adding the link, I have not tested anything related to compressing files at all...

(13 Nov '18, 10:38) Volker Barth

John is correct that we use a custom header but only if no compression algorithm is given. If you give 'zip' or 'gzip' as an algorithm, we do not use the header, making the compression compatible with outside tools.

However the name of the 'zip' algorithm is a bit misleading - it does not make the output compatible with Windows .zip files. This algorithm simply compresses data (i.e. a single file) while .zip files are a compressed archive format. If you use 'gzip' as the algorithm instead of 'zip', Windows tools should be able to decompress the data.

permanent link

answered 13 Nov '18, 10:56

Graeme%20Perrow's gravatar image

Graeme Perrow
9.6k379124
accept rate: 54%

Thanks Graeme - that all makes sense.

(13 Nov '18, 11:27) Justin Willey

I believe that although we use the standard algorithms, we add a custom header to identify encryption type and/or remove some of the headers that the file-based utilities would add. For example, zip files contain a directory of files included in the archive and that would be very expensive to include on a per-value basis.

permanent link

answered 13 Nov '18, 10:09

John%20Smirnios's gravatar image

John Smirnios
12.0k396166
accept rate: 37%

Thanks - yes that makes sense about the folder stuff being the difference.

(13 Nov '18, 11:28) Justin Willey
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×246
×22
×13

question asked: 13 Nov '18, 09:16

question was seen: 1,530 times

last updated: 13 Nov '18, 11:28