英文:
Oracle Apex/PLSQL: Can i use apex data export to store the file into another table as a blob?
问题
我正在尝试弄清如何将SQL查询的结果存储到一个BLOB列中。
当前的设置是:
我正在尝试构建一种"文件存储"的系统。用户可以上传文件,然后我将浏览这些文件,编辑它们,然后让他们有机会下载这些已编辑的文件。我正在使用Oracle Apex来完成这个任务。
因此,上传的文件以BLOB的形式存储在数据库表中,这可以通过Apex轻松实现。我希望编辑这个文件,然后再次将其作为BLOB存储到表中。
基本上,我只需要逆转上传功能,但似乎并不那么简单。
代码大致如下:
DECLARE
l_context apex_exec.t_context;
l_export apex_data_export.t_export;
BEGIN
l_context := apex_exec.open_query_context(
p_location => apex_exec.c_location_local_db,
p_sql_query => 'select * from emp' );
l_export := apex_data_export.export (
p_context => l_context,
p_format => apex_data_export.c_format_pdf );
apex_exec.close( l_context );
UPDATE my_table
SET file_blob = l_export;
EXCEPTION
when others THEN
apex_exec.close( l_context );
raise;
END;
这会给我一个错误,'PLS-00382: 表达式类型错误'。然而,文档中提到导出函数将文件导出为BLOB。是否可以通过Apex数据导出实现这一目标?
注意:如果您需要更多关于解决此问题的信息,请提供更多上下文。
英文:
I'm trying to figure out how to store the result of an sql query into a blob column.
The current setup:
I am trying to build a "File store" of sorts. Users can upload files, I will then go through those files, edit them and then give them an option to download those edited files. I'm using Oracle Apex to do this.
So the uploaded files are stored as a blob in the database table, this is done quite easily with Apex. I would like to edit this file, and store it again as a blob in the table.
Basically, I just need to reverse the upload functionality but it doesn't seem to be quite straightforward.
The code roughly likes this:
>
DECLARE
l_context apex_exec.t_context;
l_export apex_data_export.t_export;
BEGIN
l_context := apex_exec.open_query_context(
p_location => apex_exec.c_location_local_db,
p_sql_query => 'select * from emp' );
l_export := apex_data_export.export (
p_context => l_context,
p_format => apex_data_export.c_format_pdf );
apex_exec.close( l_context );
UPDATE my_table
SET file_blob = l_export;
EXCEPTION
when others THEN
apex_exec.close( l_context );
raise;
END;
This gives me an error 'PLS-00382: expression is of wrong type'. However the documentation mentions that the export function exports a file as a blob.
Is this possible to be achieved with Apex Data Export?
答案1
得分: 2
在你的代码中,l_export
的数据类型是 apex_data_export.t_export
。在文档中,你可以查看这个数据类型的具体信息。记录类型 apex_data_export.t_export
包含一个名为 content_blob
的列 - 也许你可以执行以下操作:
UPDATE my_table
SET file_blob = l_export.content_clob;
我还没有进行测试,但这是我会开始的地方。
英文:
In your code, l_export
is of datatype apex_data_export.t_export
. In the docs you can see what that datatype is exactly. Record type apex_data_export.t_export
has a column content_blob
- maybe you could do
UPDATE my_table
SET file_blob = l_export.content_clob;
I have not done any testing but this is where I'd start.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论