![]() |
VOOZH | about |
The CData Cmdlets for Oracle Service Cloud 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 Service Cloud.
The Cmdlets are not only a PowerShell interface to Oracle Service Cloud, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Oracle Service Cloud data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Oracle Service Cloud. To access Oracle Service Cloud data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Oracle Service Cloud.
Once you have acquired the necessary connection properties, accessing Oracle Service Cloud data in PowerShell can be enabled in three steps.
You must set the following to authenticate to Oracle Service Cloud:
Install the module:
Install-Module OracleServiceCloudCmdlets
Connect:
$oracleservicecloud = Connect-OracleServiceCloud -Url "$Url" -User "$User" -Password "$Password"
Search for and retrieve data:
$displayorder = "12" $accounts = Select-OracleServiceCloud -Connection $oracleservicecloud -Table "Accounts" -Where "DisplayOrder = `'$DisplayOrder`'" $accounts
You can also use the Invoke-OracleServiceCloud cmdlet to execute SQL commands:
$accounts = Invoke-OracleServiceCloud -Connection $oracleservicecloud -Query 'SELECT * FROM Accounts WHERE DisplayOrder = @DisplayOrder' -Params @{'@DisplayOrder'='12'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Oracle Service Cloud\lib\System.Data.CData.OracleServiceCloud.dll")
Connect to Oracle Service Cloud:
$conn= New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudConnection("Url=https://abc.rightnowdemo.com;User=user;Password=password;")
$conn.Open()
Instantiate the OracleServiceCloudDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, LookupName from Accounts"
$da= New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.lookupname
}
Update-OracleServiceCloud -Connection $OracleServiceCloud -Columns @('Id','LookupName') -Values @('MyId', 'MyLookupName') -Table Accounts -Id "MyId"
$cmd = New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudCommand("UPDATE Accounts SET DisplayOrder='12' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-OracleServiceCloud -Connection $OracleServiceCloud -Table Accounts -Columns @("Id", "LookupName") -Values @("MyId", "MyLookupName")
$cmd = New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudCommand("INSERT INTO Accounts (DisplayOrder) VALUES (@myDisplayOrder)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudParameter("@myDisplayOrder","12")))
$cmd.ExecuteNonQuery()
Remove-OracleServiceCloud -Connection $OracleServiceCloud -Table "Accounts" -Id "MyId"
$cmd = New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudCommand("DELETE FROM Accounts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Oracle Service Cloud Data Provider to get started:
Download NowLearn more:
👁 Oracle Service Cloud IconRapidly create and deploy powerful .NET applications that integrate with Oracle Service Cloud.