exception when calling an oracle function

G

Guest

i'm getting the exception:

Parameter 'p1': No size set for variable length data type: String.

my code follows:

OracleCommand cmd = new OracleCommand();
cmd.Connection = oraConn;
cmd.CommandText = "ops$sqltime.pa_new_job_no_fn";
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter par1 = new OracleParameter();
par1.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(par1);
par1 = new OracleParameter();
par1.Value = projectNo;
par1.Direction = ParameterDirection.Input;
cmd.Parameters.Add(par1);
int affectedRows = (int) cmd.ExecuteNonQuery();
int ljn = (int) cmd.Parameters["RETURN_VALUE"].Value;

thanks in advance
 
C

Carlos J. Quintero [.NET MVP]

I have not tested it, but Parameter has a Size property that you should set
for string types.

OracleParameter par1 = new OracleParameter();
par1.Direction = ParameterDirection.ReturnValue;
par1.Size = 4000
cmd.Parameters.Add(par1);

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
G

Guest

it didnt get rid of the exception.

Carlos J. Quintero said:
I have not tested it, but Parameter has a Size property that you should set
for string types.

OracleParameter par1 = new OracleParameter();
par1.Direction = ParameterDirection.ReturnValue;
par1.Size = 4000
cmd.Parameters.Add(par1);

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

Newbie said:
i'm getting the exception:

Parameter 'p1': No size set for variable length data type: String.

my code follows:

OracleCommand cmd = new OracleCommand();
cmd.Connection = oraConn;
cmd.CommandText = "ops$sqltime.pa_new_job_no_fn";
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter par1 = new OracleParameter();
par1.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(par1);
par1 = new OracleParameter();
par1.Value = projectNo;
par1.Direction = ParameterDirection.Input;
cmd.Parameters.Add(par1);
int affectedRows = (int) cmd.ExecuteNonQuery();
int ljn = (int) cmd.Parameters["RETURN_VALUE"].Value;

thanks in advance
 
H

Hans Kesting

Newbie said:
it didnt get rid of the exception.

You added "a" parameter, and Oracle complained specifically
about "p1". Try setting a name for your parameter.

Hans Kesting

Carlos J. Quintero said:
I have not tested it, but Parameter has a Size property that you
should set for string types.

OracleParameter par1 = new OracleParameter();
par1.Direction = ParameterDirection.ReturnValue;
par1.Size = 4000
cmd.Parameters.Add(par1);

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and
VBA You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

Newbie said:
i'm getting the exception:

Parameter 'p1': No size set for variable length data type: String.

my code follows:

OracleCommand cmd = new OracleCommand();
cmd.Connection = oraConn;
cmd.CommandText = "ops$sqltime.pa_new_job_no_fn";
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter par1 = new OracleParameter();
par1.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(par1);
par1 = new OracleParameter();
par1.Value = projectNo;
par1.Direction = ParameterDirection.Input;
cmd.Parameters.Add(par1);
int affectedRows = (int) cmd.ExecuteNonQuery();
int ljn = (int) cmd.Parameters["RETURN_VALUE"].Value;

thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top