Ik zit met het volgende probleem. Ik probreer heel netjes alle SQL uit mijn C# code te weren en werk met stored procedures. Echter wanneer ik een output parameter uit probeer te lezen krijg ik constant dezelfde fout, namelijk:
ORA-06550: line 1, column 24: PLS-00306: wrong number or types of arguments in call to 'SP_GETCOUNTRIES' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
Zelfs naar heel veel zoeken en kloten op het internet kom ik er niet uit. Overal lees je dat het moet werken maar dat doet het dus niet!
Hieronder de code van de oracle package:
PACKAGE pkgCountry AS
type tblCountryId is table of number index by binary_integer;
procedure sp_getCountries
(
o_CountryId out tblCountryId);
end pkgCountry;
<b>De package body:</b>
PACKAGE BODY pkgCountry AS
procedure sp_getCountries
(
o_CountryId out tblCountryId
)
is
cursor Cur_Country is
select COUNTRYID
from COUNTRY;
RecordCount Number Default 0;
begin
for CurRecCountry in Cur_Country loop
RecordCount := RecordCount + 1;
o_CountryId(RecordCount) := CurRecCountry.COUNTRYID;
end loop;
end sp_getCountries;
end pkgCountry;
De c# code.....
using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using Portal.Business;
namespace Portal.Persistance
{
public class dbcCountries
{
private OleDbConnection conCountries;
private OleDbCommand comCountries;
private OleDbDataReader reaCountries;
private string sSQL;
private dbcConstants ciConstants;
public dbcCountries()
{
ciConstants = new dbcConstants();
conCountries = new OleDbConnection(ciConstants.getDbConnection());
conCountries.Open();
}
public ArrayList getCountries()
{
ArrayList alCountries;
alCountries = new ArrayList();
sSQL = "pkgCountry.sp_GetCountries()";
comCountries = new OleDbCommand(sSQL,conCountries);
comCountries.CommandType = CommandType.StoredProcedure;
comCountries.Parameters.Add("o_CountryId",OleDbType.Integer,16);
comCountries.Parameters["o_CountryId"].Direction = ParameterDirection.ReturnValue;
comCountries.ExecuteNonQuery();
return alCountries;
}
}
}
ORA-06550: line 1, column 24: PLS-00306: wrong number or types of arguments in call to 'SP_GETCOUNTRIES' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
Zelfs naar heel veel zoeken en kloten op het internet kom ik er niet uit. Overal lees je dat het moet werken maar dat doet het dus niet!
Hieronder de code van de oracle package:
PACKAGE pkgCountry AS
type tblCountryId is table of number index by binary_integer;
procedure sp_getCountries
(
o_CountryId out tblCountryId);
end pkgCountry;
<b>De package body:</b>
PACKAGE BODY pkgCountry AS
procedure sp_getCountries
(
o_CountryId out tblCountryId
)
is
cursor Cur_Country is
select COUNTRYID
from COUNTRY;
RecordCount Number Default 0;
begin
for CurRecCountry in Cur_Country loop
RecordCount := RecordCount + 1;
o_CountryId(RecordCount) := CurRecCountry.COUNTRYID;
end loop;
end sp_getCountries;
end pkgCountry;
De c# code.....
using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using Portal.Business;
namespace Portal.Persistance
{
public class dbcCountries
{
private OleDbConnection conCountries;
private OleDbCommand comCountries;
private OleDbDataReader reaCountries;
private string sSQL;
private dbcConstants ciConstants;
public dbcCountries()
{
ciConstants = new dbcConstants();
conCountries = new OleDbConnection(ciConstants.getDbConnection());
conCountries.Open();
}
public ArrayList getCountries()
{
ArrayList alCountries;
alCountries = new ArrayList();
sSQL = "pkgCountry.sp_GetCountries()";
comCountries = new OleDbCommand(sSQL,conCountries);
comCountries.CommandType = CommandType.StoredProcedure;
comCountries.Parameters.Add("o_CountryId",OleDbType.Integer,16);
comCountries.Parameters["o_CountryId"].Direction = ParameterDirection.ReturnValue;
comCountries.ExecuteNonQuery();
return alCountries;
}
}
}