Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:36:16+00:00 2026-06-18T04:36:16+00:00

Ok so we have a manual process that runs through PL/SQL Developer to run

  • 0

Ok so we have a manual process that runs through PL/SQL Developer to run a query and then export to csv.

I am trying to automate that process using powershell since we are working in a windows environment.

I have created two files that seems to be exact duplicates from the automated and manual process but they don’t work the same so I assume I am missing some hidden characters but I can’t find them or figure out how to remove them.

The most obvious example of them working differently is opening them in excel. The manual file opens in excel automatically putting each column in it’s own seperate column. The automated file instead puts everything into one column.

Can anybody shed some light? I am hoping that by resolving this or at least getting some info will help with the bigger problem of it not processing correctly.

Thanks.

ex one column
“rownum”,”year”,”month”,”batch”,”facility”,”transfer_facility”,”trans_dt”,”meter”,”ticket”,”trans_product”,”trans”,”shipper”,”customer”,”supplier”,”broker”,”origin”,”destination”,”quantity”

ex seperate column
“”,”ROWNUM”,”RPT_YR”,”RPT_MO”,”BATCH_NBR”,”FACILITY_CD”,”TRANSFER_FACILITY_CD”,”TRANS_DT”,”METER_NBR”,”TKT_NBR”,”TRANS_PRODUCT_CD”,”TRANS_CD”,”SHIPPER_CD”,”CUSTOMER_NBR”,”SUPPLIER_NBR”,”BROKER_CD”,”ORIGIN_CD”,”DESTINATION_CD”,”NET_QTY”

$connectionstring = "Data Source=database;User Id=user;Password=password"
$connection = New-Object System.Data.OracleClient.OracleConnection($connectionstring)
$command = New-Object System.Data.OracleClient.OracleCommand($query, $connection)
$connection.Open()
Write-Host -ForegroundColor Black " Opening Oracle Connection"
Start-Sleep -Seconds 2

#Getting data from oracle
Write-Host
Write-Host -ForegroundColor Black "Getting data from Oracle"
$Oracle_data=$command.ExecuteReader()
Start-Sleep -Seconds 2

if ($Oracle_data.read()){
Write-Host -ForegroundColor Green "Connection Success"
while ($Oracle_data.read()) {

#Variables for recordset
$rownum = $Oracle_data.GetDecimal(0)
$rpt_yr = $Oracle_data.GetDecimal(1)
$rpt_mo = $Oracle_data.GetDecimal(2)
$batch_nbr = $Oracle_data.GetString(3)
$facility_cd = $Oracle_data.GetString(4)
$transfer_facility_cd = $Oracle_data.GetString(5)
$trans_dt = $Oracle_data.GetDateTime(6)
$meter_nbr = $Oracle_data.GetString(7)
$tkt_nbr = $Oracle_data.GetString(8)
$trans_product_cd = $Oracle_data.GetString(9)
$trans_cd = $Oracle_data.GetString(10)
$shipper_cd = $Oracle_data.GetString(11)
$customer_nbr = $Oracle_data.GetString(12)
$supplier_nbr = $Oracle_data.GetString(13)
$broker_cd = $Oracle_data.GetString(14)
$origin_cd = $Oracle_data.GetString(15)
$destination_cd = $Oracle_data.GetString(16)
$net_qty = $Oracle_data.GetDecimal(17)

#Define new file
$filename = "Pipeline" #Get-Date -UFormat "%b%Y"
$filename = $filename + ".csv"
$fileLocation = $newdir + "\" + $filename 
$fileExists = Test-Path $fileLocation

    #Create object to hold record
    $obj = new-object psobject -prop @{
        rownum = $rownum
        year = $rpt_yr
        month = $rpt_mo
        batch = $batch_nbr
        facility = $facility_cd
        transfer_facility = $transfer_facility_cd
        trans_dt = $trans_dt
        meter = $meter_nbr
        ticket = $tkt_nbr
        trans_product = $trans_product_cd
        trans = $trans_cd
        shipper = $shipper_cd
        customer = $customer_nbr
        supplier = $supplier_nbr
        broker = $broker_cd
        origin = $origin_cd
        destination = $destination_cd
        quantity = $net_qty
    }
    $records += $obj

}

}else {
Write-Host -ForegroundColor Red " Connection Failed"
}

#Write records to file with headers
$records | Select-Object      rownum,year,month,batch,facility,transfer_facility,trans_dt,meter,ticket,trans_product,trans,shipper,customer,supplier,broker,origin,destination,quantity |
ConvertTo-Csv | 
Select -Skip 1|
Out-File $fileLocation
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:36:17+00:00Added an answer on June 18, 2026 at 4:36 am

    Why are you skipping the first row(usually the headers)? Also, try using Export-CSV instead:

    #Write records to file with headers
    $records | Select-Object rownum, year, month, batch, facility, transfer_facility, trans_dt, meter, ticket, trans_product, trans, shipper, customer, supplier, broker, origin, destination, quantity |
    Export-Csv $fileLocation -NoTypeInformation
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You have an error in your SQL syntax; check the manual that corresponds to
I get: You have an error in your SQL syntax; check the manual that
Notice: You have an error in your SQL syntax; check the manual that corresponds
I have a manual process that needs to be automated. Below are the steps
I have a very large and complex MySQL query that gets run from a
I have gone through this page... http://www.php.net/manual/en/function.hash.php MD5 is 32 characters long while sha1
We have an installation program that runs in Perl 32-bit. This program needs to
I have a python process that is writing a large number of items into
I have an automated build process that I'd like to extend so I can
I have a process I would like to automate, but I am not very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.