I have an Oracle SQL table that contains email addresses. I need to extract this data and insert it into an array, and export to a csv file. I'm not too sure where to go from here. My code so far is:
$odpAssemblyName = "Oracle.DataAccess, Version=2.112.3.0,
Culture=neutral, PublicKeyToken=89b483f429c47342"
[System.Reflection.Assembly]::Load($odpAssemblyName)
$con = New-Object Oracle.DataAccess.Client.OracleConnection("User Id=HR;Password=oracle;Data Source=XE")
$cmd=$con.CreateCommand()
$cmd.CommandText= @"
SELECT DISTINCT email FROM
hr.emails WHERE acct_enabled = 'Y'
AND UPPER(email) NOT LIKE 'AIS%'ORDER BY email
"@
$con.Open()
$rdr=$cmd.ExecuteReader()
$columnNames=$rdr.GetSchemaTable() | Select-Object -ExpandProperty ColumnName
$resultSet=@()
while ($rdr.Read()) {
$intData=$rdr.GetOracleString(0)
"{0,0}" -f $intData.Value
}
$con.Close()
Can anybody help me with my While loop (I'm new to programming mostly) and help me add the result set to an array, and export the result set to a nice little csv file?
Thanks in advance for any help/pointers
James
email, right? This CSV file will just be a list of emails, each email on its own line, with no commas at all, right? Just curious why you mention CSV... this will look like a text file