I already have working examples like the following, to essentially get results from a SQL query from C#:
Order GetOrder(int orderId)
{
List<OracleParameter> parameters = new()
{
new("Id", OracleDbType.Varchar2, orderId, ParameterDirection.Input)
};
OracleDataReader reader = await GetDataReaderAsync(connection, "my_package.GetOrder", parameters);
... //read the results
======
PROCEDURE GetOrder(Id in number,results out sys_refcursor) IS
BEGIN
Open results for
Select
buyer, orderDate, cost
from Order
WHERE Id = Id
END GetOrder;
But I am stuck trying to make a version GetOrders(List<int> orderIds)
. I have already come across OracleParameter.CollectionType and I have read several questions:
- Passing array to Oracle procedure from c#
- Passing an array of data as an input parameter to an Oracle procedure
- Retrieve the vales of PLSQLAssociativeArray In C#
Each addresses a different piece but I cannot anywhere find an end-to-end example. I'm not an Oracle guy though - though I can write queries, creating a procedure I rely on finding an example and copying it with modifications. This stuff about associative arrays and defining custom PLSQL types is just confusing me, especially if I have to create a type for each procedure... I only understand simple scalar DB types not passing tables as parameters.
Could anyone show me (or point me to the duplicate answer I can't find) a rough outline of how I'd create a GetOrders version of the above - the changes made in C# & PL/SQL to handle the List parameter?