加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

oracle – APEX:从临时表下载BLOB

发布时间:2021-01-19 21:55:12 所属栏目:站长百科 来源:网络整理
导读:我正在实行行使Oracle APEX 4.1.1构建一个简朴的查察应用措施.要表现的信息位于差异数据库的表中,然后是包括APEX应用措施会见的模式的数据库.行使View(RemoteTableView)和 Database Link会见此长途表. View按预期事变,包罗Oracle无法通过数据库链接选择LOB列

我正在实行行使Oracle APEX 4.1.1构建一个简朴的查察应用措施.要表现的信息位于差异数据库的表中,然后是包括APEX应用措施会见的模式的数据库.行使View(RemoteTableView)和 Database Link会见此长途表. View按预期事变,包罗Oracle无法通过数据库链接选择LOB列项.

在APEX应用措施中,我按照Oracle Application Express Advanced Tutorials中的声名界说了一个进程(DownloadFiles),只要必要下载View中的BLOB,就会运行该进程(DownloadFiles)

当APEX应用措施构建在包括BLOB项目标现有表上时,这很是有效,没有题目.

可是,在RemoteTableView上,该进程略有差异.其他代码行添加到DownloadFiles进程中,每当挪用视图中的项目举办下载时,将现实的BLOB从RemoteTableView插入姑且表(TempTable).然后在TempTable上挪用DownloadFile来下载(此刻当地存储的)BLOB. (这样做是为了绕过通过DB-Link直接选择LOB项目).没有COMMIT.

不幸的是,每当挪用该项目时,APEX应用措施城市失败并表现“未找到此网页.未找到该网址的网页:… / f?p = 101:7:1342995827199601 :: NO :: P7_DOC_ID :3001” .

对这个题目的研究证明是徒劳的.插入进程按预期事变(在PL / SQL Developer中),而且可以轻松下载任何其他当地表中的任何其他BLOB.

因此题目是,为什么APEX应用措施无法处理赏罚这种环境.行使姑且表或插入我应该留意的语句时是否有限定?另外,下载LOB工具的最佳做法是什么.

具体声名插入行和下载BLOB的进程. (我实行过差异的要领).此PL / SQL块称为“在标头之前加载”,:P2_BLOB_ID用标识符列值添补到BLOB列.

DECLARE
  v_mime      VARCHAR2(48);
  v_length    NUMBER(38);
  v_file_name VARCHAR2(38);
  Lob_loc     BLOB;
BEGIN
  DELETE FROM [TemporaryTable];
  --
  INSERT INTO [TemporaryTable]( [attr1],[attr2],[blob],[mime] )
  SELECT [attr1],[mime]
  FROM   [RemoteTableView]
  WHERE  [attr1] = :P2_BLOB_ID
  AND    ROWNUM  = 1;
  --
  SELECT [mime],[attr1],DBMS_LOB.GETLENGTH( [blob] )
  INTO   v_mime,lob_loc,v_file_name,v_length
  FROM   [TemporaryTable]
  WHERE  [attr1] = :P2_BLOB_ID;
  --
  owa_util.mime_header( nvl(v_mime,'application/octet'),FALSE );
  htp.p('Content-length: ' || v_length);
  htp.p('Content-Disposition:  attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
  owa_util.http_header_close;
  wpg_docload.download_file( Lob_loc );
END;

办理要领

实行在wpg_docload挪用后添加 apex_application.stop_apex_engine.这将停止进一步输出HTTP标头,也许会导致下载,由于会天生更多的极点代码.

owa_util.mime_header( nvl(v_mime,null)|| '"');
  owa_util.http_header_close;
  wpg_docload.download_file( Lob_loc );
  apex_application.stop_apex_engine;

另外,具体声名:

Are there limitations when working with temporary tables or insert
statements that I should be aware of?

是.但不必然在你的环境下.重要的是要记着apex在数据库会话方面的事变道理. Apex是无状态的,可以行使毗连池.极点会话凡是与1个数据库会话不匹配,而且您永久不能担保,譬喻,在渲染和处理赏罚之间行使沟通的数据库会话.这也在Understanding Session State Management的文档中扼要说起,为利便起见复制:

HTTP,the protocol over which HTML pages are most often delivered,is
a stateless protocol. A web browser is only connected to the server
for as long as it takes to download a complete page. In addition,each
page request is treated by the server as an independent event,
unrelated to any page requests that happened previously or that may
occur in the future. To access form values entered on one page on a
subsequent page,the values must be stored as session state. Oracle
Application Express transparently maintains session state and provides
developers with the ability to get and set session state values from
any page in the application.

2.4.1 What Is a Session?

A session is a logical construct that establishes persistence (or
stateful behavior) across page views. Each session is assigned a
unique identifier. The Application Express engine uses this identifier
(or session ID) to store and retrieve an application’s working set of
data (or session state) before and after each page view.

Because sessions are entirely independent of one another,any number
of sessions can exist in the database at the same time. A user can
also run multiple instances of an application simultaneously in
different browsers.

Sessions are logically and physically distinct from Oracle database
sessions used to service page requests. A user runs an application in
a single Oracle Application Express session from log in to log out
with a typical duration measured in minutes or hours. Each page
requested during that session results in the Application Express
engine creating or reusing an Oracle database session to access
database resources. Often these database sessions last just a fraction
of a second.

对付全局姑且表,这意味着在很多环境下行使它是没故意义的,由于数据将仅存在于当前数据库会话中.这方面的一个例子是,人们可以在onload中的某个位置加载GTT中的数据,而且意味着在提交后的历程或ajax挪用中行使它.桌子很有也许是空的.
然而,Apex提供了apex_collection情势的更换方案,它将暂且生涯给定极点会话中的数据.

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读