通过 SAS 将 SQL Server Blob 字段导出到文件

发布于 2024-10-18 08:35:18 字数 836 浏览 5 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文