SQLLDR:动态加载连接完整路径和文件名的 lobfile

发布于 2025-01-08 06:12:37 字数 1089 浏览 0 评论 0原文

我正在使用 sQLLDER (11g) 将数据加载到表中。其中一列是 BLOB,需要从另一个文件加载。文件的名称取决于表的字段,我需要连接完整路径才能加载文件。因此,为了获得文件的完整路径,我需要将文件夹路径“/oradata/val/”与字段 ID_RECOMMENDATION 加上扩展名“.dat”连接起来;例如,如果字段 ID_RECOMMENDATION 为“1”,则文件名应为“/oradata/val/1.dat”。我无法修改原始文件,所以我想使用表达式来获取文件的完整路径,使用如下内容:

LOAD DATA
INFILE *
INTO TABLE t_val_recommendation append
fields terminated by ';'
(
  ID_RECOMMENDATION,
  ID_PROFILE       ,
  START_DATE       date 'yyyymmdd',
  LOBF_00001       BOUNDFILLER"trim('/oradata/val/'||:ID_RECOMMENDATION||'.dat')",
  PARAGRAPHS       LOBFILE (LOBF_00001) TERMINATED BY EOF,
  ASSET_ALLOCATION
)

但它似乎不理解路径和文件名的串联。我怎样才能做到这一点?

谢谢

(编辑以澄清含义)

这是表架构:

  ID_RECOMMENDATION  NUMBER(10)                 NOT NULL,             
  ID_PROFILE         VARCHAR2(10 BYTE)          NOT NULL,
  START_DATE         DATE                       NOT NULL,
  PARAGRAPHS         SYS.XMLTYPE,
  ASSET_ALLOCATION   SYS.XMLTYPE

这将是要加载的行:

1;CONSERVATIVE;20120301;<aa>This is my asset allocation</aa>

I'm using sQLLDER (11g) to load data into a table. One of the columns is a BLOB, that needs to be loaded from another file. The name of the file depends on a field of the table, and I need to concatenate the full path in order to be able to load the file. So in order to have the full path of the file, I need to concatenate the folder path '/oradata/val/' with the field ID_RECOMMENDATION plus the extension '.dat'; for example, if the field ID_RECOMMENDATION is '1', the filename should be '/oradata/val/1.dat'. I can not modify the original file, so I want to use an expression to get the full path for the file, using something like this:

LOAD DATA
INFILE *
INTO TABLE t_val_recommendation append
fields terminated by ';'
(
  ID_RECOMMENDATION,
  ID_PROFILE       ,
  START_DATE       date 'yyyymmdd',
  LOBF_00001       BOUNDFILLER"trim('/oradata/val/'||:ID_RECOMMENDATION||'.dat')",
  PARAGRAPHS       LOBFILE (LOBF_00001) TERMINATED BY EOF,
  ASSET_ALLOCATION
)

But it doesn't seem to understand the concatenation of the path and filename. How can I do that?

thanks

(Edited to clarify meaning)

This is the table schema:

  ID_RECOMMENDATION  NUMBER(10)                 NOT NULL,             
  ID_PROFILE         VARCHAR2(10 BYTE)          NOT NULL,
  START_DATE         DATE                       NOT NULL,
  PARAGRAPHS         SYS.XMLTYPE,
  ASSET_ALLOCATION   SYS.XMLTYPE

And this would be a line to be loaded:

1;CONSERVATIVE;20120301;<aa>This is my asset allocation</aa>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无力看清 2025-01-15 06:12:37

我不确定修改正在加载的现有文件有多困难,但是是否可以修改这些文件以使其包含正确的文件路径?您可以使用 Java 或其他文本处理语言将 ID_RECOMMENDATION 与 '/oradata/val/' & 连接起来。 '.dat' 并保存文件,然后使用以下命令加载到文件中将是一个简单的更改...

LOAD DATA
INFILE *
INTO TABLE t_val_recommendation append
fields terminated by ';'
(
  ID_RECOMMENDATION,
  ID_PROFILE       ,
  START_DATE       date 'yyyymmdd',
  LOBF_00001       FILLER char,
  PARAGRAPHS       LOBFILE (LOBF_00001) TERMINATED BY EOF
)

有许多可用的语言易于学习和执行文本文件转换。 Java、Perl 和我首先想到的是 C# 三种,但还有许多其他可用的。

我想说,从长远来看,以 SQLLDR 易于使用的格式设置文本文件是非常值得的。

I'm not sure how hard it would be for you to modify the existing file(s) that are being loaded in, but is it possible to modify those files to already contain the correct file path? You could possibly use Java or some other text processing language to concatenate that ID_RECOMMENDATION with '/oradata/val/' & '.dat' and save the file(s) and then it would be a simple change to load in your file(s) using...

LOAD DATA
INFILE *
INTO TABLE t_val_recommendation append
fields terminated by ';'
(
  ID_RECOMMENDATION,
  ID_PROFILE       ,
  START_DATE       date 'yyyymmdd',
  LOBF_00001       FILLER char,
  PARAGRAPHS       LOBFILE (LOBF_00001) TERMINATED BY EOF
)

There's many languages available that are easy to learn and do text file transformations. Java, Perl & C# are three that come right to mind but there are many others available.

I would say setting up your text files in a format that will be easy to use by SQLLDR will be well worth the effort in the long run.

闻呓 2025-01-15 06:12:37
LOBF_00001       BOUNDFILLER"trim('/oradata/val/'||:ID_RECOMMENDATION||'.dat')"

这对我来说似乎是一个错误:

  • 如果这是一个 BOUNDFILLER,则意味着您的表 t_val_recommendation 中NO 名为 LOBF_00001 的列,但是 ctl 文件的数据部分中有数据,您想要使用它并将其存储到 LOBF_00001 变量中,该变量可用于计算其他表达式。
  • 如果这是一个EXPRESSION,则意味着您的表t_val_recommendation一个名为LOBF_00001的列,但是ctl 文件的数据部分中没有数据。
LOBF_00001       BOUNDFILLER"trim('/oradata/val/'||:ID_RECOMMENDATION||'.dat')"

this seems a mistake to me:

  • if this is a BOUNDFILLER, it means that there is NO column named LOBF_00001 in your table t_val_recommendation, but that there is data in your data section of the ctl file, that you want to consume it and store it into the LOBF_00001 variable, that can be used to compute other expressions.
  • if this is an EXPRESSION, it means that there is a column named LOBF_00001 in your table t_val_recommendation, but that there is NO data in the data section of the ctl file.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文