在 CTL 中使用参数

发布于 2024-10-09 10:00:05 字数 279 浏览 1 评论 0原文

我正在使用 CTL 文件将文件中存储的数据加载到 Oracle 数据库中的特定表。 目前,我使用以下命令行启动加载程序文件:

sqlldr user/pwd@db data=my_data_file control=my_loader.ctl

我想知道是否可以使用在 CTL 文件中检索的指定参数。

另外,是否可以检索 CTL 用于填充表的数据文件的名称?我也想为每一行插入它。我目前必须调用一个过程来更新以前插入的记录。

任何帮助将不胜感激!

I am using a CTL file to load data stored in a file to a specific table in my Oracle database.
Currently, I launch the loader file using the following command line:

sqlldr user/pwd@db data=my_data_file control=my_loader.ctl

I would like to know if it is possible to use specify parameters to be retrieved in the CTL file.

Also, is it possible to retrieve the name of the data file used by the CTL to fill the table ?I also would like to insert it for each row. I currently have to call a procedure to update previously inserted records.

Any help would be appreciated !

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

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

发布评论

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

评论(1

守不住的情 2024-10-16 10:00:05

据我所知,没有任何方法可以在 ctrl 中将参数作为变量传递。
但是您可以在 ctl 中使用常量并修改 clt 文件以在每次加载时更改该常量值(在 ctl 文件内容中)。

编辑:更具体。

my_loader.ctl:

--options
load data
infile 'c:\$datfilename

dataload.bat:假设$datfilename$ 是文本,将被数据文件的名称替换。

::sample copy
copy my_loader.ctl my_loader_temp.ctl

::replace the name of datafile (mainly the content to load into table's data column)
findandreplace my_loader_temp.ctl "$datafilename$" "%1"

::load
sqlldr user/pwd@db data=%1 control=my_loader_temp.ctl
::or with data be obmitted if you specified by infile in control file.
sqlldr user/pwd@db control=my_loader_temp.ctl

使用:dataload.bat mydatafile_2010_10_10.txt

--this is optional, you can specify here or from command line into table mytable fields.... ( datafilename constant '$datfilename

dataload.bat:假设$datfilename$ 是文本,将被数据文件的名称替换。


使用:dataload.bat mydatafile_2010_10_10.txt

, -- will be replace by real datafname each load datacol1 char(1), .... )

dataload.bat:假设$datfilename$ 是文本,将被数据文件的名称替换。

使用:dataload.bat mydatafile_2010_10_10.txt

As I know don't have any way to pass parametter as variable in ctrl.
But You can use constant in ctl and modify clt file to change that constant value (in ctl file content) for every loading times.

Edit: more specific.

my_loader.ctl:

--options
load data
infile 'c:\$datfilename

dataload.bat: assume that $datfilename$ is the text will be replace by datafile's name.

::sample copy
copy my_loader.ctl my_loader_temp.ctl

::replace the name of datafile (mainly the content to load into table's data column)
findandreplace my_loader_temp.ctl "$datafilename$" "%1"

::load
sqlldr user/pwd@db data=%1 control=my_loader_temp.ctl
::or with data be obmitted if you specified by infile in control file.
sqlldr user/pwd@db control=my_loader_temp.ctl

using: dataload.bat mydatafile_2010_10_10.txt

--this is optional, you can specify here or from command line into table mytable fields.... ( datafilename constant '$datfilename

dataload.bat: assume that $datfilename$ is the text will be replace by datafile's name.


using: dataload.bat mydatafile_2010_10_10.txt

, -- will be replace by real datafname each load datacol1 char(1), .... )

dataload.bat: assume that $datfilename$ is the text will be replace by datafile's name.

using: dataload.bat mydatafile_2010_10_10.txt

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文