繁体   English   中英

OLEDB将Oracle LONG数据类型截断为100个字符

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM