[英]OLEDB truncating Oracle LONG datatype to 100 characters
我想我知道解決方案,但我想征求第二意見。
我有一個名為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
}
好的,所以我找到了問題的根源。
當使用此sql語句從具有LONG數據類型的表中選擇時:
Select * from [table]
OLEDB從ORACLE返回LONG字段的全部內容
當使用以下查詢代替同一表時:
Select distinct * from [table]
OLEDB僅返回LONG字段的前100個字符
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.