你好!
我有一个数据表,它是通过运行两个单独的查询(提供来自两个不同源的数据)的脚本生成的,然后将它们合并以形成数据表。 我的问题是关于每天更新此表的方式,不需要从一开始就重新运行脚本,并且可以保留任何清理/调整/新列。 我看到侧边栏上有“从数据库更新”和“从数据库2更新”。 我可以运行其中一个,但它将删除该源中未包含的列(即,如果我运行“从数据库更新”,这是第一个查询,它将删除列 TVC、VI、AC 和 DC来自查询 2 以及其他计算/手动输入列,我在合并到原始脚本后添加到表中)。
我尝试将两个更新脚本一起复制到一个脚本中(见下文),但有一个问题,当它运行第一个脚本时,它将尝试在运行第二个脚本之前删除列。 我不确定最好的方法是否是合并表格,然后尝试更新,或者是否有更简单的方法(也许有一种方法可以在不删除不是来自该源的数据的情况下进行更新)? 我删除了连接信息并更改了下面代码中的名称,但希望这有助于提供一个想法。 以前有人处理过类似的问题吗? 谢谢!
New SQL Query(
Version( 130 ),
Connection(
""
),
QueryName( "query1" ),
Select(
Column( "Assay", "t1" ),
Column( "Experiment", "t1" ),
Column( "Date", "t1", Numeric Format( "m/d/y h:m:s", "0", "NO", "" ) ),
Column( "G", "t1" ),
Column( "L", "t1" ),
Column( "N", "t1" ),
Column( "K", "t1" ),
Column( "C", "t1" ),
Column( "H", "t1" ),
Column( "O", "t1" ),
Column( "C", "t1" ),
),
From( Table( "Runs", Schema( "schema1" ), Alias( "t1" ) ) ),
Where(
Contains(
Column( "Experiment", "t1" ),
"E001",
UI(
Contains(
Base(
"Categorical",
Prompt(
"Experiment ID:",
Character,
PromptName( "t1.Experiment_1" )
)
)
)
)
) & Does Not Contain(
Column( "Assay, "t1" ),
"xxx",
UI(
Contains(
Base(
"Categorical",
Prompt(
"Add a filter for names (optional) or put xxx:",
Character,
PromptName( "t1.AssayId_1" )
)
)
)
)
) & GE(
Column(
"Date",
"t1",
Numeric Format( "m/d/y h:m:s", "0", "NO", "" )
),
0,
UI(
Comparison(
Base(
"Continuous",
Prompt(
"Date range:",
Character,
PromptName( "t1.RunDate_1" )
)
)
)
)
)
)
) << Run Foreground( UpdateTable( Current Data Table() ) );
New SQL Query(
Version( 130 ),
Connection(
""
),
QueryName( "query2" ),
Select(
Column( "Assay", "t2" ),
Column( "Experiment", "t2" ),
Column( "Date", "t2", Numeric Format( "m/d/y h:m:s", "0", "NO", "" ) ),
Column( "TVC", "t2" ),
Column( "VI", "t2" ),
Column( "AC", "t2" ),
Column( "AD", "t2" )
),
From( Table( "Runs", Schema( "schema2" ), Alias( "t2" ) ) ),
Where(
Contains(
Column( "Experiment", "t2" ),
"E001",
UI(
Contains(
Base(
"Categorical",
Prompt(
"Experiment ID:",
Character,
PromptName( "t2.Experiment_1" )
)
)
)
)
) & Does Not Contain(
Column( "Assay", "t2" ),
"xxx",
UI(
Contains(
Base(
"Categorical",
Prompt(
"Add a filter (optional) or put xxx:",
Character,
PromptName( "t2.AssayId_1" )
)
)
)
)
) & GE(
Column(
"Date",
"t2",
Numeric Format( "m/d/y h:m:s", "0", "NO", "" )
),
0,
UI(
Comparison(
Base(
"Continuous",
Prompt(
"Date range:",
Character,
PromptName( "t2.RunDate_1" )
)
)
)
)
)
)
) << Run Foreground( UpdateTable( Current Data Table() ) )