Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sqlps事务问题_Sql_Powershell_Ssas_Sqlps - Fatal编程技术网

sqlps事务问题

sqlps事务问题,sql,powershell,ssas,sqlps,Sql,Powershell,Ssas,Sqlps,我编写了一个使用sqlps部署SSAS表格多维数据集的脚本。在部署之后,我需要对多维数据集执行一些操作,但是如果我尝试访问它,我会收到一条消息说多维数据集不存在。但事实上,如果我将操作拆分为两个脚本(deploy->exit sql ps->new sqlps session),它是可以工作的(因为现在不重要的原因,我不能这样做) sqlps会话似乎没有看到它刚刚部署的多维数据集。我想知道是否可以运行刷新命令,或者是否可以在“读取未限制”状态下运行sqlps。是否使用支持的cmdlet?看起来只

我编写了一个使用sqlps部署SSAS表格多维数据集的脚本。在部署之后,我需要对多维数据集执行一些操作,但是如果我尝试访问它,我会收到一条消息说多维数据集不存在。但事实上,如果我将操作拆分为两个脚本(deploy->exit sql ps->new sqlps session),它是可以工作的(因为现在不重要的原因,我不能这样做)

sqlps会话似乎没有看到它刚刚部署的多维数据集。我想知道是否可以运行刷新命令,或者是否可以在“读取未限制”状态下运行sqlps。

是否使用支持的cmdlet?看起来只有在脚本用完后才提交事务

尝试将部署逻辑拆分为两个事务:创建多维数据集和需要执行的其他操作。对于每个部分,您都应该使用自己的事务,如下所示:

Start-PSTransaction
// logic
Complete-PSTransaction
using(CurrentPsTransaction)
{
   ... // Perform transactional work here
}

... // Perform non-transacted work here

using(CurrentPsTransaction)
{
   ... // Perform more transactional work here
}
如果需要以编程方式访问事务,则应在PowerShell中使用Cmdlet属性中的
TransactionScope
analog,如下所示:

Start-PSTransaction
// logic
Complete-PSTransaction
using(CurrentPsTransaction)
{
   ... // Perform transactional work here
}

... // Perform non-transacted work here

using(CurrentPsTransaction)
{
   ... // Perform more transactional work here
}
更新:
您是否可以使用声明打开事务

为事务开发–Cmdlet和提供程序声明 cmdlet声明对事务的支持的方式与声明对ShouldProcess的支持的方式类似:

[Cmdlet(“Get”, “Process”, SupportsTransactions=True)]
提供者通过ProviderCapabilities标志声明其对事务的支持:

[CmdletProvider(“Registry”, ProviderCapabilities.Transactions)]
有关Powershell中隔离级别的更多信息:


您好,我似乎无法运行Start-PSTransaction,我收到一条消息“术语“Start-PSTransaction”无法识别为cmdlet、函数、脚本文件或可操作程序的名称”。我只尝试了“Start-Transaction”,它没有失败,但似乎也没有实际启动事务,因为问题仍然存在。什么主意?感谢您给出了答案,但无法确定它是否有用。@Diego可能是您应该在PS脚本中添加一些模块。我试图将[Cmdlet(“Get”,“Process”,SupportsTransactions=True)]添加到脚本顶部,但它抱怨语法问题error@Diego无法确定如何排除这个问题。也许你可以提供一些代码来调查?