I am trying to insert a PDF into a database as BLOB using the code below
> [System.Reflection.Assembly]::LoadWithPartialName("System.Data.OracleClient")
>
$constr = "User Id=USER;Password=$password;Data Source=DB"
Try {
>
$filePath = 'C:\TEST PDF.pdf' $Stream = Format-Hex -LiteralPath
>
$filePath $queryString = "INSERT INTO TEST_TABLE (first_name, blob_data) VALUES (:one, :two)"
$connection = New-Object System.Data.OracleClient.OracleConnection($constr) $connection.Open()
$command = New-Object System.Data.OracleClient.OracleCommand($queryString, $connection)
$command.Parameters.Add("one", "SP_ERROR_ALERT")
$command.Parameters.Add("two", $Stream) $command.ExecuteNonQuery()
$connection.Close()
} Finally {
if ($connection -ne $null)
{
$connection.Close()
$connection.Dispose()
}
if ($command -ne $null)
{
$command.Dispose()
}
}
I have tried as many different ways I can think of but keep hitting an error complaining about the size of the BLOB. To test if would work I did an insert from another table containing Blobs and that worked fine - I therefore suspect my encoding.....
The error message I get is:
Exception calling "ExecuteNonQuery" with "0" argument(s): "Unknown datatype System.Object[]
for parameter value of type Object."
Get-Contentcmdlet with-AsByteStream?