导入前运行脚本 [英] Running script before import
问题描述
我不需要详细解释一个解决方案(虽然我不会想起b $ b)但是我希望有人能告诉我一般的最佳路径
完成任务,因为我不知道我所拥有的所有
能力。我可以自己学习细节
我想。我试图将其设置为尽可能简单使用
,因为其他人将每周或每天导入数据。
我需要导入一些文本文件,但在导入之前必须运行perl脚本,并且必须在
导入过程中使用某些逻辑。
我正在使用访问项目作为SQL服务器的前端
数据库。
运行perl脚本之后:
当文本中的行文件是导入的,然后我需要先检查表格,以确定我当前表格中是否有任何主键
不在导入的文本文件中,如果是不是,那么我
需要更新记录中某个列的值,该值在我的表中,而不是在导入的数据中。我要么想要一个
" IsInImport"作为标志的列,在导入之前,为所有记录设置
this为false,并且当我导入数据时,我会将此
标志设置为true导入数据中的记录根据主键匹配写入我的
表中的记录。这意味着在
结束时导入我表中的所有记录,但导入时不会导致
的值仍为false,我可以运行我的他们的逻辑
做了所需的更新。
或许我应该将数据导入临时表,并使用
更新查询通过比较我当前的表和
导入表来执行上述逻辑?
我推测我可能需要写这个VB使用
命令运行外部应用程序并将命令行参数传递给我的perl脚本
。
我的其他推测正在使用dts包。我认为设置上述更新逻辑比在vb中执行此操作更容易。
也许在访问vb中我可以运行外部perl脚本,然后调用
DTS套餐?
提前感谢任何帮助。显而易见的是,我在上面提到的任何事情上都没有什么经验,但我很快就学会了b $ b并且我不想浪费时间学习一些东西。发现它没有b $ b不能做我想要的,或者不加思索地做到这一点。
I don''t need a detailed description of a solution(although I wouldn''t
mind), but I am hoping someone could tell me in general the best path
to go about accomplishing a task, since I don''t know all the
capabilities of what I have available. I can learn the details myself
I think. I am trying to set this up to be as simple to use as possible
since others will be importing data on a weekly or daily basis.
I need to import some text files, but have a perl script that must be
run on them prior to importing, and some logic must be used in the
importing process also.
I am using an "Access Project" as the front end to an SQL server
database.
After running the perl script:
When the rows in the text file are imported, then I need to first
examine the table to determine if any primary keys in my current table
are not in the text file being imported, and if they are not, then I
need to update the value of a certain column in the record that is in
my table but not in the imported data. I was either thinking having a
"IsInImport" column that acts as a flag, and prior to import, setting
this to false for all records, and as I import data, I would set this
flag to true when a record in the import data writes to a record in my
table based on a primary key match. This would mean at the end of
import all records that were in my table, but not in the import would
still have a value of false, and I could run my logic for them that
does the needed updates.
Or perhaps I should import the data into a temporary table, and use an
update query to do the above logic by comparing my current table and
the import table?
I speculate that I will probably need to write this in VB using the
command for running an external app and passing command line parameters
to my perl script.
My other speculation is using a dts package. I am thinking it would be
easier to setup the above updating logic than doing this in vb.
Perhaps in vb from access I can run my external perl script, then call
the DTS package?
Thanks in advance for any help at all. It should be obvious that I
have little experience in anything mentioned above, but I learn quickly
and just don''t won''t to waste time learning something to find that it
can''t do what I want it to, or obliviously doing it the hard way.
推荐答案
我已经为此工作了一些。我正在尝试使用导入数据创建
临时数据库的方法,然后使用嵌套的NOT IN查询
删除原始表中不在的项目导入的
数据。
事情是它们与复合主键相关。
我' 我对如何编写查询感到困惑。
I''ve worked on this some. I am trying to use the method of creating a
temporary database with imported data, then use a nested NOT IN query
to delete items in the original table that are not in the imported
data.
The thing is they are related by a compound primary key.
I''m a little confused on how to write the query.
我已经找到了选择查询,它给了我想要的项目
删除:
SELECT dbo.nedpitfields。*
FROM dbo.nedpitfields LEFT OUTER JOIN
dbo。 testpitfields ON dbo.nedpitfields.Field3 =
dbo.testpitfields.Field3 AND dbo.nedpitfields.Field10 =
dbo.testpitfields.Field10
WHERE (dbo.testpitfields.Field10是空的)
但我现在正试图将其变为删除查询。但是无法想象如何。
I''ve figured out the select query that gives me the items I want to
delete:
SELECT dbo.nedpitfields.*
FROM dbo.nedpitfields LEFT OUTER JOIN
dbo.testpitfields ON dbo.nedpitfields.Field3 =
dbo.testpitfields.Field3 AND dbo.nedpitfields.Field10 =
dbo.testpitfields.Field10
WHERE (dbo.testpitfields.Field10 IS NULL)
But I am now trying to make this into a delete query. But can''t figure
out how.
sh ****** @ cs.fsu.edu 写道:
我已经找到了给我项目的选择查询想要删除:
SELECT dbo.nedpitfields。*
FROM dbo.nedpitfields LEFT OUTER JOIN
dbo.testpitfields ON dbo.nedpitfields.Field3 =
dbo.testpitfields.Field3 AND dbo.nedpitfields.Field10 =
dbo.testpitfields.Field10
WHERE(dbo.testpitfields.Field10 IS NULL)
但我现在正试图将其转换为删除查询。但是无法想象
如何。
I''ve figured out the select query that gives me the items I want to
delete:
SELECT dbo.nedpitfields.*
FROM dbo.nedpitfields LEFT OUTER JOIN
dbo.testpitfields ON dbo.nedpitfields.Field3 =
dbo.testpitfields.Field3 AND dbo.nedpitfields.Field10 =
dbo.testpitfields.Field10
WHERE (dbo.testpitfields.Field10 IS NULL)
But I am now trying to make this into a delete query. But can''t figure
out how.
替换SELECT dbo.nedpitfields。* FROM与DELETE FROM
-
MGFoster ::: mgf00< at> earthlink< decimal-point> net
奥克兰,加利福尼亚州(美国)
Replace "SELECT dbo.nedpitfields.* FROM" with "DELETE FROM"
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
这篇关于导入前运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!