我想用SQL Anywhere 17获取事务开始时间戳。
在Powershell中的示例脚本下面:
Add-Type -AssemblyName ("Sap.Data.SQLAnywhere.v4.5, Version=17.0.8.40434, Culture=neutral, PublicKeyToken=f222fc4333e0d400")
$connectionString = "DSN=My_Source;DBN=My_Database;UID=My_User;PWD=My_Password;"
$conn = New-Object Sap.Data.SQLAnywhere.SAConnection($connectionString)
$conn.Open()
$cmd = New-Object Sap.Data.SQLAnywhere.SACommand('SELECT NOW()', $conn)
$cmd.Transaction = $conn.BeginTransaction([System.Data.IsolationLevel]'ReadCommitted')
$dt = New-Object System.Data.DataTable
0..1 | % {
Start-Sleep $_
$reader = $cmd.ExecuteReader()
$dt.Clear()
$dt.Load($reader)
Write-Host $dt.Rows[0].ItemArray[0]
}
$cmd.Transaction.Rollback()
$cmd.Dispose()
$conn.Close()
输出:
6/4/2018 11:40:01 AM 6/4/2018 11:40:02 AM
正如您所看到的,对NOW()函数的连续调用提供了越来越多的时间戳 我确实尝试使用" SELECT CURRENT TIME"也没有成功。
有什么建议吗?