I am so mad at oracle. I have been battling to get two values (output paramaters) from oracle database. I need to get two values (o_unallocated_ledgercode and o_allocated_ledgercode) based on paymentType and vendor.
What issue is: these values remain null in C#. I cannot get these values from database. what may be wrong? please look at my c# codes. i need someone's different perspective. I may have missed something. Please give me code example. Thanks!
Oracle package:
CREATE OR REPLACE package body BANKIMPORTS.pkg_vendor_config as
PROCEDURE get_ledger_codes (i_vendor in varchar2,
i_payment_type in varchar2,
o_allocated_ledgercode out varchar2,
o_unallocated_ledgercode out varchar2) is
BEGIN
IF UPPER (i_payment_type) = 'SUBS' THEN
SELECT CV.CONFIGVALUE
INTO o_unallocated_ledgercode
FROM VENDOR v
JOIN VENDOR_CONFIG_ITEM_VALUE CV ON v.Id = CV.Vendor_Id
JOIN CONFIG_ITEMS c ON CV.Config_Item_Id = c.Config_Item_Id
WHERE C.ITEMNAME = 'Subs_Unallocated_LederCode'
AND V.DESCRIPTION = i_vendor;
SELECT CV.CONFIGVALUE
INTO o_allocated_ledgercode
FROM VENDOR v
JOIN VENDOR_CONFIG_ITEM_VALUE CV ON v.Id = CV.Vendor_Id
JOIN CONFIG_ITEMS c ON CV.Config_Item_Id = c.Config_Item_Id
WHERE C.ITEMNAME = 'Subs_Payment_LedgerCode'
AND V.DESCRIPTION = i_vendor;
ELSIF UPPER (i_payment_type) = 'GOTV'
........same select statement as above
C# codes:
using (DbCommand command = connection.CreateCommand())
{
try
{
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "pkg_vendor_config.get_ledger_codes";
command.AddParameter("i_vendor", DbType.String, vendor, ParameterDirection.Input);
command.AddParameter("i_payment_type", DbType.String, paymentType, ParameterDirection.Input);
command.AddParameter("o_unallocated_ledgercode", DbType.String, ParameterDirection.Output);
command.AddParameter("o_allocated_ledgercode", DbType.String, ParameterDirection.Output);
command.ExecuteNonQuery();
var unallocated = (String)command.Parameters["o_unallocated_ledgercode"].Value;
var allocated = (String)command.Parameters["o_allocated_ledgercode"].Value;