我想我知道這個解決方案,但我想獲得第二個意見。OLEDB將Oracle LONG數據類型截斷爲100個字符
我有一個名爲Get-Data的函數,它從Oracle數據庫中檢索並返回一個DataTable。現在,由於Powershell超級有用,當從Oracle返回一條記錄時,該函數將返回DataRow而不是DataTable。
發生這種情況並且其中一列是LONG DataType時,該字段被截斷爲100個字符。
明顯的解決辦法是返回$ dt並修改我的代碼來處理該問題。但是,正如我所說,我想要第二個意見。
獲取-數據:
function Get-Data
{
[Cmdletbinding()]
Param
(
[Parameter(Position=0,Mandatory=$True)]$Conn,
[Parameter(Position=1,Mandatory=$True)]$sql
)
#Open the connection to the DB if closed
if($Conn.state -eq 'Closed')
{
$Conn.open()
}
#Create objects for querying the DB
$readcmd = New-Object system.Data.OleDb.OleDbCommand($sql,$Conn)
$readcmd.CommandTimeout = '300'
$da = New-Object system.Data.OleDb.OleDbDataAdapter($readcmd)
$dt = New-Object system.Data.datatable
#Query the DB and fill the DataTabe with records
[void]$da.fill($dt)
return $dt
}
我試圖返回,dt的變化,無濟於事。只要返回一條記錄,問題就會一直存在。 –