- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想也许我开始在这里得到这个过程,但它太奇怪了,我怀疑自己。下面看评论,有什么乱七八糟的地方。
DECLARE
srcFile BFILE := BFILENAME('SOME_DIR', 'xyz.pdf');
fLen NUMBER;
dest BLOB;
BEGIN
INSERT INTO SomeTable
VALUES ( 1, 'xyz.pdf', EMPTY_BLOB(), null ) -- Does this establish an active ref.?
RETURNING pdf_file INTO dest;
DBMS_LOB.OPEN(srcFile, dbms_lob.file_readonly);
fLen := dbms_lob.getlength(srcFile);
DBMS_LOB.LOADFROMFILE(dest, srcFile, fLen); -- Does this reach into the table row,
-- and fill it with the file’s contents?
dbms_lob.close(srcFile);
commit;
END;
下面的方法是更新已经存在的行中的 BLOB 吗?
DECLARE
srcFile BFILE := BFILENAME('SOME_DIR', 'xyz.pdf');
fLen NUMBER;
dest BLOB;
BEGIN
SELECT pdf_file INTO dest -- Does this est. an active reference?
FROM SomeTable
WHERE ID = 1; -- ( <———<<< ' = 1' is just for example.)
DBMS_LOB.OPEN(srcFile, dbms_lob.file_readonly);
fLen := dbms_lob.getlength(srcFile);
DBMS_LOB.LoadFromFile(dest, srcFile, fLen); -- Does this reach into the row,
-- filling it w/ the file’s contents?
dbms_lob.close(srcFile);
commit;
END;
这看起来更像是 .NET 对数据库适配器以及 FileInfo、DirInfo 函数的处理。但我在 Oracle 的其他任何地方都没有看到这种理念。
我早就料到了
BLOBVariable = LoadFromFile(srcLocator, byteCnt); -- where the func. rtrns a val,
跟着
INSERT INTO SomeTable (pdf_file)
VALUES (BLOBVariable);
我没看错吗?如果是这样,什么时候放弃引用?我似乎记得读过使用“LoadFromFile?”时不需要“提交”的内容?
现在,今天早上我看到了一个示例(没有解释),它选择 BLOB 字段到一个变量中,使用 FOR UPDATE 来锁定记录。了解这是怎么回事可能会很好......
-- Lock the record
execute immediate 'SELECT pdf_file INTO dest
FROM image_blobs
WHERE itl_image_blob_id = :1
FOR UPDATE'
INTO v_blob_data
using < the row identifier goes here >;
-- Read the file
dbms_lob.loadfromfile(dests, srcFile, fLen);
-- update the blob field
execute immediate '
UPDATE image_blobs
SET pdf_file = :1
WHERE itl_image_blob_id = :2'
using dest, < row identifier >;
最佳答案
以下内容表明我的理智完好无损,INSERT 语句确实创建了 loadfromfile()
使用的引用。这个关于 INSERT 语句的答案足以满足我的目的,因此我将假设 UPDATE 功能是相似的。 'IMPORT_DIR'
是数据库中的命名数据库目录。
DROP TABLE TEST_BLOBS purge; -- 'purge' prevents loading up the recycle bin.
CREATE TABLE TEST_BLOBS (
ID VARCHAR(4),
F_NAME VARCHAR2(50 BYTE),
CONTENT_TYPE VARCHAR2(50 BYTE),
F_SIZE NUMBER(10),
BLOB_DATA BLOB DEFAULT empty_blob() );
DECLARE
dest blob; tmp_id varchar2(4);
v_f_sz NUMBER(10); b_file BFILE := NULL;
fName VARCHAR2 (50);
CURSOR get_items IS SELECT filename FROM My_Table_of_names;
BEGIN
FOR a_rec IN get_items LOOP
fName := a_rec.filename;
b_file := BFILENAME ( 'IMPORT_DIR', fName );
IF DBMS_LOB.fileexists (b_file) = 0 THEN
-- Report the problem and exit.
END IF;
DBMS_LOB.fileopen ( b_file, DBMS_LOB.file_readonly );
v_f_sz := DBMS_LOB.getlength (b_file);
INSERT INTO test_blobs ( ID, content_type, f_name, f_size, blob_data )
VALUES ( <Some_ID_val>, 'application/pdf', fName, v_f_sz, empty_blob() )
RETURNING blob_data, ID INTO dest, tmp_id;
-- Table field contains data, (HUGEBLOB),
-- when debugging and loop ends here.
DBMS_LOB.loadfromfile(dest, b_file, v_f_sz);
DBMS_LOB.close(b_file);
-- After running this, the variable tmp_id has the value that was assigned in the INSERT statement,
-- and the table’s fields, 'BLOB_Data', have the contents of the files. dest is indeed a reference
-- to the row and field, allowing LoadFromFile() to put data into the table.
END LOOP;
END;
/
关于oracle - DBMS_LOB.LoadFromFile 完整性检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50805798/
我想要一些概念上的澄清。为了证明问题是 NP 完全的,我们使用归约。 现在假设我有 L<=L'。是从 L 减少到 L' 还是我也可以用相反的方式来减少?即我能否证明如果 L 可以使用 L' 求解,那么
考虑不相交的哈密顿路径问题: 输入:一个可能是有向或无向的图 输出:此图是否至少存在 2 条边不相交的哈密顿路径?边不相交意味着没有一条边被两条路径共享。 证明不相交哈密顿路径是 np-完全的。 有人
我理解为什么有界度生成树被认为是度数为 2 的 NP 完全(这是哈密顿路径问题的一个实例),但我不明白为什么这适用于度数 > 2。如果有人可以解释一下为什么这是大于 2 的 NP 完全问题,这将是最有
我正在实现一个 Django 网站,其中上传的文件在保存到服务器 (/media) 之前使用用户提供的 key 进行加密。当用户希望查看它们时,系统会提示他们输入 key ,加密文件被解密,然后显示给
我想用nodejs列出指定目录中的所有文件。 var fs = require('fs'); var path = require('path'); var walk = function(direc
在我的文件夹 assets/data 中,有很多包含我的应用静态数据的 XML 文件。 对于某人来说,检索 APK、修改其中的一部分并安装到设备上真的很容易。 我想通过检查我的 assets/data
我正在努力将我的备份脚本从 shell 转换为 Python。我的旧脚本的功能之一是通过执行以下操作检查创建的 tarfile 的完整性:gzip -t。 这在 Python 中似乎有点棘手。 似乎唯
我正在尝试将包含带有单独 CSS 和 js 文件的 HTML 脚本的 php 文件导入另一个包含我的页眉和页脚的 php 文件。页眉和页脚来自一个模板,该模板使用非常困惑和令人费解的 CSS,基本上对
使用 Flask,我试图验证 cookie 没有被篡改。现在,如果我更改 cookie 值,它只会抛出一个错误,但我想检查代码 is_valid(session['user_id']) 并重定向/重置
在 PHP(和 MySQL)中,我们有许多技术来确保输入的数据有效且安全。添加斜杠、MySQL 的转义字符串和正则表达式是我们经常使用的一些。 我已经看到此链接,该链接对该主题进行了非常初步的介绍,但
下面的代码使用了不安全的 GeneralizedNewtypeDeriving扩展中断 Data.Set通过插入具有不同 Ord 的不同元素实例: {-# LANGUAGE GeneralizedNe
我刚刚在 NPM 上创建了一个新包(这非常简单),我对如何维护包的完整性感兴趣。任何人都可以发布软件包的新版本吗?或者这仅限于我的用户帐户? 如果任何人都可以发布对包的更改,如何监控他们的修改以确保项
我正在尝试使用 Dapper 和 SQLite 来追踪 C# 项目中的数据库损坏错误。所以我正在寻找一种方法来检查代码中的数据库完整性。我发现多个地方说我可以为此发送命令“PRAGMAintegrit
yarn 安装抛出: EACCES: permission denied, unlink '/home/minnak/Darbas/market/node_modules/.yarn-integrit
上下文: 我有 open-sourced a repository ,由 Travis-CI 测试。特拉维斯提供 build-notification用于测试运行的钩子(Hook),因此您可以在 IR
我是一名优秀的程序员,十分优秀!