通过 SAS 将 SQL Server Blob 字段导出到文件
我正在开发一个 SAS 接口,通过 SAS 将存储在 SQL Server 中的图片导出为 blob 字段。我的问题是试图让 SAS 在从数据库读取数据和将其写入文件之间不“摆弄”数据。
到目前为止,我已经能够检索图像并将其写入文件大小大约正确的文件(即在 100 字节内),因此当我尝试显示生成的图像文件时,它已损坏。
如果我将工作图片与生成的图片进行比较,看起来有些行中插入了换行符并导致损坏。作为测试,如果我尝试手动纠正这些线路故障,那么我可以让图像在屏幕上渲染,但它在视觉上已损坏。
我的想法是,问题在于我用来保存图像的格式,无论是在创建工作表时的 put 语句中。我希望一些 SAS 格式专家可以在这里帮助我......
LIBNAME sphoto ODBC <...omitted> DBMAX_TEXT=32767;
proc sql noprint;
create table work.PHOTOS as
SELECT
photo as ImageData format=$32767. informat=$32767.
FROM
sphoto.Photos
WHERE ...
;
quit;
data _null_;
set work.PHOTOS;
file "image_sas.jpg";
put ImageData;
run;
更新
请参阅下面的评论,将文件语句更改为此,它现在正在工作。
文件“/home/221741D/cardax/image_sas.jpg”LRECL=32767 NOPRINT NOTAB;
I am working on a SAS interface to export pictures stored within SQL Server as blob fields via SAS. My problem is trying to get SAS to not 'fiddle' with the data in between reading it from the DB and writing it to a file.
So far I've been able to retrieve an image and write it to a file with a file size approximately correct (ie within 100 bytes), consequently when I try displaying the resulting image file it is corrupted.
If I diff a working picture with the generated one, it looks like some lines have had a newline inserted in them and caused the corruption. As a test, if I try to manually correct these line glitches then I can get the image to render on the screen, but it is visually corrupted.
My thinking is that the problem lies in the formats I am using to save the image, either in the put statement when I create the work table. I'm hoping that some SAS format guru can help me out here....
LIBNAME sphoto ODBC <...omitted> DBMAX_TEXT=32767;
proc sql noprint;
create table work.PHOTOS as
SELECT
photo as ImageData format=$32767. informat=$32767.
FROM
sphoto.Photos
WHERE ...
;
quit;
data _null_;
set work.PHOTOS;
file "image_sas.jpg";
put ImageData;
run;
UPDATE
See comment below, changed the file statement to this and it is working now.
file "/home/221741D/cardax/image_sas.jpg" LRECL=32767 NOPRINT NOTAB;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论