473,384 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,384 software developers and data experts.

Call a package function from C#: PLS-00306

Hi,

I'm trying to call an Oracle package function from C#, but I keep getting the same error: PLS-00306: wrong number or types of arguments in call to 'F_CTCPREPAREP151HEADER'.

This is the function declaration in the package:
function f_CtcPrepareP151Header
(
as_codjal in varchar2/*,
ad_datdoc in varchar2,
as_codfnr in varchar2,
ad_dtfafo in varchar2,
as_reffnr in varchar2,
as_vcs in varchar2,
as_devfnr in varchar2,
ad_datech in varchar2,
al_totdev in number,
al_tvadev in number,
al_tvafac in number,
as_codtva in varchar2,
as_libele in varchar2,
as_xlogcr in varchar2,
as_typesc in varchar2,
al_pouesc in number,
al_jouesc in number,
al_docrec in number,
as_msglan in varchar2*/,
rs_msgerr in out varchar2
)
return integer;

This is the function declaration in the package body:
function f_CtcPrepareP151Header
(
as_codjal in varchar2/*,
ad_datdoc in varchar2,
as_codfnr in varchar2,
ad_dtfafo in varchar2,
as_reffnr in varchar2,
as_vcs in varchar2,
as_devfnr in varchar2,
ad_datech in varchar2,
al_totdev in number,
al_tvadev in number,
al_tvafac in number,
as_codtva in varchar2, -- tvaspe
as_libele in varchar2, -- numero de bon de commande (texte libre)
as_xlogcr in varchar2,
as_typesc in varchar2,
al_pouesc in number,
al_jouesc in number,
al_docrec in number, -- numero de document Recomatics (ctcd15.des001)
as_msglan in varchar2*/,
rs_msgerr in out varchar2
)
return integer
is
begin
/*rs_msgerr := 'test';*/
return 1;
end f_CtcPrepareP151Header;

This is the way I call the function:
OleDbCommand l_oCmd1 = new OleDbCommand("PKG_TEMREC.f_ctcPrepareP151Header", l_oConContractor);
l_oCmd1.CommandType = CommandType.StoredProcedure;

l_strExtraInfo = "f_ctcPrepareP151Header : Create return parameter";
OleDbParameter l_RetValue1 = l_oCmd1.Parameters.Add("RetVal", OleDbType.Integer);
l_RetValue1.Direction = ParameterDirection.ReturnValue;

l_strExtraInfo = "f_ctcPrepareP151Header : Create journal parameter";
OleDbParameter l_oJournalPar1 = new OleDbParameter("as_codjal", OleDbType.VarChar);
l_oJournalPar1.Direction = ParameterDirection.Input;
l_oJournalPar1.Value = l_strJournal;
l_oJournalPar1.Size = l_strJournal.Length;
l_oCmd1.Parameters.Add(l_oJournalPar1);

l_strExtraInfo = "f_ctcPrepareP151Header : Create message parameter";
OleDbParameter l_oErrMsgPar1 = l_oCmd1.Parameters.Add("rs_msgerr", OleDbType.VarChar);
l_oErrMsgPar1.Direction = ParameterDirection.InputOutput;
l_oErrMsgPar1.Size = 4000;
l_oErrMsgPar1.Value = new String(' ', 4000);

try
{
ExecuteFunction(l_oCmd1, l_oConContractor, l_oTrans, l_RetValue1, l_oErrMsgPar1, "f_ctcPrepareP151Header");
}
catch (Exception e)
{
throw new Exception("Error while preparing invoice header: " + e.Message);
}

The function ExecuteFunction is the following:
private void ExecuteFunction(OleDbCommand oCmd, OleDbConnection oConn, OleDbTransaction oTrans, OleDbParameter oRetValue, OleDbParameter oErrMsg, string strFunctionName)
{
try
{
oCmd.Transaction = oTrans;
oCmd.ExecuteNonQuery();

if ((oRetValue != null) && (oRetValue.Value != null))
{
int iOutputValue = Convert.ToInt32(oRetValue.Value.ToString());
if (iOutputValue < 0)
{
throw new Exception(oErrMsg.Value.ToString());
}
}
}
catch (Exception e)
{
string l_strMsg = string.Format("Exception in procedure PKG_TEMREC." + strFunctionName + " - " + e.Message + "(" + oCmd.CommandText + ")");
throw new Exception(l_strMsg);
}
}

Can anybody tell me what I am doing wrong? I know that I have commented out a lot of parameters in the function declaration, but this is for testing purposes.

Thanks,

Kristof.
Oct 2 '09 #1
2 4293
debasisdas
8,127 Expert 4TB
why are you trying to execute a function ? simply use it in SQL statement and pass the list of parameters.
Oct 3 '09 #2
Then how about the in/out parameter?
Oct 5 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kid A | last post by:
I am writing stored proecdures on Oracle 9 (release 1 I believe). I am having difficulty creating a stored procedure that makes a remote function call to a database on a different host. On the...
1
by: Per Magnus L?vold | last post by:
Hi, I am trying to create a package under the apps schema, and I keep getting PLS-00201 and ORA-00942 when refering to types from other apps-packages and other views / tables. I even get this...
1
by: Onder Kaya | last post by:
Hello everyone, We are trying the compile this package but we get this error. PACKAGE BODY APPS.XNC_BOM_PVT On line:32 PLS-00358:'ASSEMBLY_ITEM_ID' exists in more than one table, use...
2
by: M | last post by:
Hello I am trying to build an Oracle PL/SQL Package. Some functions should only be visible from the package, while other functions need to be called from outside. I tried the following: --...
0
by: navedkhan | last post by:
here is the scenario i hav an .net application which works on Oracle database 1. I created an application installer in .net it worked fine 2. Then i created a database installer in .net...
0
debasisdas
by: debasisdas | last post by:
PACKAGE WITH LOCAL FUNCTION ============================= create or replace package my_pkg as procedure my_proc(arg1 in varchar2); function my_fun(arg1 in number) return varchar2; end my_pkg;...
2
by: gagandutta01 | last post by:
Hi, Can anyone tell me how to execute a function declared in Oracle Package from Unix shell script? I created a shell script and after connecting to oracle database i am using exec @...
0
debasisdas
by: debasisdas | last post by:
The following thread contains some useful tips/sample codes regarding PACKAGES in oracle, that the forum members may find useful. A package is a collection of procedures,functions,cursors,global...
0
debasisdas
by: debasisdas | last post by:
SAMPLE PACKAGE EX#3 ==================== PACKAGE SPECIFICATION -------------------------------------------- CREATE OR REPLACE PACKAGE MYPACK AS PROCEDURE SHOWENAME(EMPID IN NUMBER); FUNCTION...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.