![]() |
VOOZH | about |
The CData Cmdlets for Oracle Sales are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Oracle Sales.
The Cmdlets are not only a PowerShell interface to Oracle Sales, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Oracle Sales data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Oracle Sales. To access Oracle Sales data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Oracle Sales.
Once you have acquired the necessary connection properties, accessing Oracle Sales data in PowerShell can be enabled in three steps.
Oracle Sales uses Basic authentication over SSL; after setting the following connection properties, you are ready to connect:
Install the module:
Install-Module OracleSalesCloudCmdlets
Connect:
$oraclesalescloud = Connect-OracleSalesCloud -HostURL "$HostURL" -Username "$Username" -Password "$Password"
Search for and retrieve data:
$createdby = "Jack" $opportunities = Select-OracleSalesCloud -Connection $oraclesalescloud -Table "Opportunities" -Where "CreatedBy = `'$CreatedBy`'" $opportunities
You can also use the Invoke-OracleSalesCloud cmdlet to execute SQL commands:
$opportunities = Invoke-OracleSalesCloud -Connection $oraclesalescloud -Query 'SELECT * FROM Opportunities WHERE CreatedBy = @CreatedBy' -Params @{'@CreatedBy'='Jack'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Oracle Sales\lib\System.Data.CData.OracleSalesCloud.dll")
Connect to Oracle Sales:
$conn= New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudConnection("HostURL=https://my.host.oraclecloud.com; Username=abc123; Password=abcdef;")
$conn.Open()
Instantiate the OracleSalesCloudDataAdapter, execute an SQL query, and output the results:
$sql="SELECT OptyId, Name from Opportunities"
$da= New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.optyid $_.name
}
Update-OracleSalesCloud -Connection $OracleSalesCloud -Columns @('OptyId','Name') -Values @('MyOptyId', 'MyName') -Table Opportunities -Id "MyId"
$cmd = New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudCommand("UPDATE Opportunities SET CreatedBy='Jack' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-OracleSalesCloud -Connection $OracleSalesCloud -Table Opportunities -Columns @("OptyId", "Name") -Values @("MyOptyId", "MyName")
$cmd = New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudCommand("INSERT INTO Opportunities (CreatedBy) VALUES (@myCreatedBy)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudParameter("@myCreatedBy","Jack")))
$cmd.ExecuteNonQuery()
Remove-OracleSalesCloud -Connection $OracleSalesCloud -Table "Opportunities" -Id "MyId"
$cmd = New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudCommand("DELETE FROM Opportunities WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleSalesCloud.OracleSalesCloudParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Oracle Sales Data Provider to get started:
Download NowLearn more:
👁 Oracle Sales IconRapidly create and deploy powerful .NET applications that integrate with Oracle Sales marketing automation platform including Leads, Contacts, Opportunities, Accounts, and more!