Database Reference
In-Depth Information
$FullPath=(get-variable myinvocation -scope script).value.
Mycommand.Definition
}
if (Test-Path $FullPath)
{
return (Split-Path $FullPath)
}
else
{
$FullPath=(Get-Location).path
Write-Warning ("Get-ScriptDirectory: Powershell Host <" +
$Host.name `
+ "> may not be compatible with this function, the
current directory <" `
+ $FullPath + "> will be used.")
return $FullPath
}
}
2.
Establish a connection as in past recipes:
$conn = Connect-Oracle (Get-ConnectionString)
Define a SQL select statement. Here we get employee with manager
data:
$sql = @"
SELECT e.employee_id,
e.first_name || ' ' || e.last_name employee,
j.job_title, e.hire_date,
m.first_name || ' ' || m.last_name manager
FROM employees e
JOIN jobs j
ON e.job_id = j.job_id
JOIN employees m
ON e.manager_id = m.employee_id
"@
3.
Populate a DataTable , set its table name, and close the connection:
$dt = Get-DataTable $conn $sql
$dt.TableName = "Employee"
$conn.Close()
4.
Add the script's directory to the location stack and remove any *.HR.* output iles
there. This is a clean-up step for iles we will create shortly.
Push-Location (Get-ScriptDirectory)
Remove-Item *.HR.* -force
 
Search WWH ::




Custom Search