@@ -165,6 +165,38 @@ function Invoke-DBOQuery {
165
165
)
166
166
167
167
begin {
168
+ function Write-HostTable {
169
+ Param (
170
+ $Table
171
+ )
172
+ $format = " "
173
+ $totalLength = 0
174
+ if ($Table ) {
175
+ for ($i = 0 ; $i -lt $Table.Columns.Count ; $i ++ ) {
176
+ $maxLength = if ($Table.Rows.Count -eq 0 ) { 0 } else {
177
+ $Table.Rows | Foreach-Object { $len = 0 } {
178
+ $itemLength = ([string ]$_.ItemArray [$i ]).Length
179
+ if ($itemLength -gt $len ) { $len = $itemLength }
180
+ } { ($len + 2 ) }
181
+ }
182
+ if ($Table.Columns [$i ].ColumnName.Length -gt $maxLength ) { $maxLength = $Table.Columns [$i ].ColumnName.Length }
183
+ $format += " {$i , $maxLength } |"
184
+ $totalLength += ($maxLength + 3 )
185
+ }
186
+ $format = " |$format "
187
+ $totalLength += 1
188
+
189
+ Write-Host ([string ]::new(' -' , $totalLength ))
190
+ Write-Host ($format -f $Table.Columns.ColumnName )
191
+ Write-Host ([string ]::new(' -' , $totalLength ))
192
+ foreach ($row in $Table.Rows ) {
193
+ Write-Host ($format -f $row.ItemArray )
194
+ }
195
+ Write-Host ([string ]::new(' -' , $totalLength ))
196
+ # totals
197
+ Write-Host (" {0, $totalLength }" -f " ($ ( $Table.Rows.Count ) rows)" )
198
+ }
199
+ }
168
200
}
169
201
process {
170
202
$config = New-DBOConfig - Configuration $Configuration
@@ -275,7 +307,10 @@ function Invoke-DBOQuery {
275
307
$command.CommandText = $splitQuery
276
308
foreach ($key in $Parameter.Keys ) {
277
309
$null = switch ($Type ) {
278
- Oracle { $command.Parameters.Add ($key , $Parameter [$key ]) }
310
+ Oracle {
311
+ $command.BindByName = $true
312
+ $command.Parameters.Add ($key , $Parameter [$key ])
313
+ }
279
314
default { $command.Parameters.AddWithValue ($key , $Parameter [$key ]) }
280
315
}
281
316
}
@@ -347,33 +382,7 @@ function Invoke-DBOQuery {
347
382
}
348
383
if ($Interactive ) {
349
384
# output right to the screen
350
- $format = " "
351
- $totalLength = 0
352
- $t = $ds.Tables [0 ]
353
- for ($i = 0 ; $i -lt $t.Columns.Count ; $i ++ ) {
354
- $maxLength = if ($t.Rows.Count -eq 0 ) { 0 } else {
355
- $t.Rows | Foreach-Object { $len = 0 } {
356
- $itemLength = ([string ]$_.ItemArray [$i ]).Length
357
- if ($itemLength -gt $len ) { $len = $itemLength }
358
- } { ($len + 2 ) }
359
- }
360
- if ($t.Columns [$i ].ColumnName.Length -gt $maxLength ) { $maxLength = $t.Columns [$i ].ColumnName.Length }
361
- $format += " {$i , $maxLength } |"
362
- $totalLength += ($maxLength + 3 )
363
- }
364
- $format = " |$format "
365
- $totalLength += 1
366
- if ($t ) {
367
- Write-Host ([string ]::new(' -' , $totalLength ))
368
- Write-Host ($format -f $t.Columns.ColumnName )
369
- Write-Host ([string ]::new(' -' , $totalLength ))
370
- foreach ($row in $t.Rows ) {
371
- Write-Host ($format -f $row.ItemArray )
372
- }
373
- Write-Host ([string ]::new(' -' , $totalLength ))
374
- # totals
375
- Write-Host (" {0, $totalLength }" -f " ($ ( $t.Rows.Count ) rows)" )
376
- }
385
+ Write-HostTable - Table $ds.Tables [0 ]
377
386
}
378
387
else {
379
388
# output as object
0 commit comments