条件逻辑不适用于我的查询。
因此,参考上面的查询,我在表上检查表是否具有相同的版本号和修订号具有唯一约束,它会错误地标识id值相同,这很好,但是我必须写一个条件逻辑说,只要有可变的ex.Message中出现错误消息,则代码不应该执行并要求重新加载软件包。我的条件逻辑存在问题,无法找到ex.Message,我该如何使它工作。
<#@ import namespace="System.Data" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Windows.Forms" #>
<#@ assembly name=
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll"
#>
<#
var ErrorMessage = ex.Message;
if (ErrorMessage == null)
{
var timeout = 3600;
var is_sharded = (src_db=="online"||src_db=="launch")? 1 :
0;
var is_boss_foxpro_src = (src_db=="boss_foxpro")? 1: 0;
var connector_type = (is_boss_foxpro_src == 1)? "_ole":"";
var src_type = (is_boss_foxpro_src == 1)?
"OleDb":"AdoNet";
var parallel_threads = 1;
var enable_package_configurations = 1;
switch(src_db)
{
case "online":
parallel_threads = 10;
break;
case "launch":
parallel_threads = 2;
break;
case "boss_foxpro":
parallel_threads = 11;
break;
default:
parallel_threads = 1;
break;
}
var shard_filter = (is_sharded == 1 || is_boss_foxpro_src == 1) ? "WHERE
shard_id =\" + (DT_STR, 10, 1252) @[User::shard_id] + \"":"";
}
else
{
MessageBox.Show("String is not empty or null");
}
#>
<Packages>
<
-- ETL code here
>
<# 尝试 {
string queryString = "INSERT INTO [audit].Biml_Expansions( DBName, SchemaName, TableName, PackageName, ExpansionType, VersionNumber, RevisionNumber ) VALUES (@DBName, @SchemaName, @TableName, @PackageName, @ExpansionType, @VersionNumber, @RevisionNumber)";
string connectionString = "Server=HQ-DEV-SQLDW01;Database=IM_STAGE;Integrated Security=True;";
System.Data.SqlClient.SqlConnection connection = new
System.Data.SqlClient.SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new
System.Data.SqlClient.SqlCommand(queryString, connection);
connection.Open();
System.Data.SqlClient.SqlParameter DBName = new
System.Data.SqlClient.SqlParameter();
DBName.ParameterName = "@DBName";
DBName.Value = tgt_db;
System.Data.SqlClient.SqlParameter SchemaName = new
System.Data.SqlClient.SqlParameter();
SchemaName.ParameterName = "@SchemaName";
SchemaName.Value = tgt_schema;
System.Data.SqlClient.SqlParameter TableName = new
System.Data.SqlClient.SqlParameter();
TableName.ParameterName = "@TableName";
TableName.Value = tgt_table;
System.Data.SqlClient.SqlParameter PackageName = new
System.Data.SqlClient.SqlParameter();
PackageName.ParameterName = "@PackageName";
PackageName.Value = "pkg_"+tgt_schema+"_"+tgt_table+".dtsx";
System.Data.SqlClient.SqlParameter ExpansionType = new
System.Data.SqlClient.SqlParameter();
ExpansionType.ParameterName = "@ExpansionType";
ExpansionType.Value = "Load";
System.Data.SqlClient.SqlParameter VersionNumber = new
System.Data.SqlClient.SqlParameter();
VersionNumber.ParameterName = "@VersionNumber";
VersionNumber.Value = version_num;
System.Data.SqlClient.SqlParameter RevisionNumber = new
System.Data.SqlClient.SqlParameter();
RevisionNumber.ParameterName = "@RevisionNumber";
RevisionNumber.Value = revision_num;
command.Parameters.Add(DBName);
command.Parameters.Add(SchemaName);
command.Parameters.Add(TableName);
command.Parameters.Add(PackageName);
command.Parameters.Add(ExpansionType);
command.Parameters.Add(VersionNumber);
command.Parameters.Add(RevisionNumber);
command.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.Show( "Error: " + ex.Message);
}
The name ex doesn't exist in the current context