473,387 Members | 1,942 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,387 software developers and data experts.

Trying to call stored procedure in Oracle from C#?

132 100+
Hello there.
I am going in bit of a circle with this matter;

First some background: I am trying to upload the details of a CSV file into an Oracle table. I am using a StreamReader to copy a line at a time into an array, using a

string[] columns = line.Split(separators.ToCharArray());

command.

Here is a definition of the table I am loading into:
======================================
UPRN NUMBER (12)
USRN NUMBER (18)
SAO_START_NUMBER NUMBER (4)
SAO_START_SUFFIX VARCHAR2 (1 Byte)
SAO_END_NUMBER NUMBER (4)
SAO_END_SUFFIX VARCHAR2 (1 Byte)
SAO_TEXT VARCHAR2 (90 Byte)
PAO_START_NUMBER NUMBER (4)
PAO_START_SUFFIX VARCHAR2 (1 Byte)
PAO_END_NUMBER NUMBER (4)
PAO_END_SUFFIX VARCHAR2 (1 Byte)
PAO_TEXT VARCHAR2 (90 Byte)
STREET_DESCRIPTOR VARCHAR2 (100 Byte)
LOCALITY_NAME VARCHAR2 (35 Byte)
TOWN_NAME VARCHAR2 (30 Byte)
ADMINISTRATIVE_AREA VARCHAR2 (30 Byte)
POST_CODE VARCHAR2 (8 Byte)
BLPU_LOGICAL_STATUS NUMBER (1)
LPI_LOGICAL_STATUS NUMBER (1)
BLPU_CLASS VARCHAR2 (4 Byte)
X_COORDINATE NUMBER (9,2)
Y_COORDINATE NUMBER (9,2)
LOCAL_CUSTODIAN_CODE NUMBER (4)
BLPU_LAST_UPDATE_DATE DATE
SAON VARCHAR2 (100 Byte)
PAON VARCHAR2 (100 Byte)
FULL_ADDRESS VARCHAR2 (548 Byte)
=========================================

Now using a stored procedure, I am trying to insert values from the CSV file into the Database, here is the stored procedure:

----------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE SADAS_MANAGER.nlpg_insert_24

(
p_uprn in number,
p_lpi_log_stat in number,
p_blpu_date in date,
p_sao_start_num in number,
p_sao_start_suf in varchar2,
p_sao_end_num in number,
p_sao_end_suf in varchar2,
p_sao_text in varchar2,
p_pao_start_num in number,
p_pao_start_suf in varchar2,
p_pao_end_num in number,
p_pao_end_suf in varchar2,
p_pao_text in varchar2,
p_usrn in number,
p_post_code in varchar2
)

IS

BEGIN

insert into NLPG_UK
(UPRN, LPI_LOGICAL_STATUS,SAO_START_NUMBER, SAO_START_SUFFIX, SAO_END_NUMBER, SAO_END_SUFFIX, SAO_TEXT, PAO_START_NUMBER,
PAO_START_SUFFIX, PAO_END_NUMBER, PAO_END_SUFFIX, PAO_TEXT, USRN, POST_CODE)
VALUES (
p_uprn,
p_lpi_log_stat,
p_sao_start_num,
p_sao_start_suf,
p_sao_end_num,
p_sao_end_suf,
p_sao_text,
p_pao_start_num,
p_pao_start_suf,
p_pao_end_num,
p_pao_end_suf,
p_pao_text,
p_usrn,
p_post_code
)
;
END;
------------------------------------------------------------------------

and here is the code in the c# that I am using to invoke the stored procedure:

************************************************** ********
insCmd.Parameters.Add("p_uprn", OleDbType.UnsignedInt).Value = columns[3];
insCmd.Parameters.Add("p_lpi_log_stat", OleDbType.Char).Value = columns[6];
insCmd.Parameters.Add("p_blpu_date", OleDbType.Date).Value = Convert.ToDateTime(columns[10]);
insCmd.Parameters.Add("p_sao_start_num", OleDbType.Integer).Value = Convert.ToInt32(columns[11]);
insCmd.Parameters.Add("p_sao_start_suf", OleDbType.Char).Value = columns[12].Length == 2 ? "" : columns[12].Substring(2, 1);
insCmd.Parameters.Add("p_sao_end_num", OleDbType.Integer).Value = Convert.ToInt32(columns[13]);
insCmd.Parameters.Add("p_sao_end_suf", OleDbType.Char).Value = columns[14].Length == 2 ? "" : columns[14].Substring(2, 1);
insCmd.Parameters.Add("p_sao_text", OleDbType.Char).Value = columns[15];
insCmd.Parameters.Add("p_pao_start_num", OleDbType.Integer).Value = Convert.ToInt32(columns[16]);
insCmd.Parameters.Add("p_pao_start_suf", OleDbType.Char).Value = columns[17].Length == 2 ? "" : columns[17].Substring(2, 1);
insCmd.Parameters.Add("p_pao_end_num", OleDbType.Integer).Value = Convert.ToInt32(columns[18]);
insCmd.Parameters.Add("p_pao_end_suf", OleDbType.Char).Value = columns[19].Length == 2 ? "" : columns[19].Substring(2, 1);
insCmd.Parameters.Add("p_pao_text", OleDbType.Char).Value = columns[20];
insCmd.Parameters.Add("p_usrn", OleDbType.Integer).Value = Convert.ToInt32(columns[21]);
insCmd.Parameters.Add("p_post_code", OleDbType.Char).Value = columns[24].Length > 2 ? columns[24].Substring(2, (columns[24].Length - 2)) : "";
insCmd.Parameters.Add("p_post_code", OleDbType.Char).Value = columns[24].Length > 2 ? columns[24].Substring(2, (columns[24].Length - 2)) : "";

insCmd.ExecuteNonQuery();
************************************************** ***********************
When I run this I am getting a constant error message of:

"Value was either too large or too small for a UInt32." This is for the first entry of:

insCmd.Parameters.Add("p_uprn", OleDbType.UnsignedInt).Value = columns[3];

Any ideas what I need to do here to enable the value to be passed to the Database please, as I have tried several options now and all fall flat?

Thank you.

Mark :o)
Nov 28 '08 #1
2 2971
1. Use OracleType instead of OleDbType
2. use watch to see the problem value
Nov 28 '08 #2
E11esar
132 100+
Thank you for that response, it has got me past that particular error situation now. :)
Nov 28 '08 #3

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

Similar topics

1
by: robin via SQLMonster.com | last post by:
I've tried several different way to execute a oracle stored procedure from a DTS package but to no avail. I have a Linked Server setup which does bring back Oracle tables from the server when I...
1
by: John Sidney-Woollett | last post by:
Is it possible to call a Postgres stored function (as if it were a procedure), using a PreparedStatement which will receive no return value, instead of having to use a CallableStatement and ignore...
3
by: Mike P | last post by:
Is it possible to return a dataset from a stored procedure, or would you need to write the SQL in your .cs file to return the dataset? Any assistance would be really appreciated. Cheers, ...
12
by: Newbie | last post by:
how can i call an oracle function to get data without using a select statement or stored procedures? given a project_no, i need to call the function: ops$sqltime.pa_new_job_no_fn which will...
3
by: Marcin Wasilewski | last post by:
Hi, I have a problem with calling procedure with parametrs. After run this code: .... Set strCommand = New ADODB.Command strCommand.ActiveConnection = cnn strCommand.CommandText =...
0
by: istruttorenuoto | last post by:
hi! I have some problems to call a stored procedure from an Unix Script. Here's the script stty istrip stty erase ^H export ORACLE_BASE=/product/oracle export...
2
by: Problematic coder | last post by:
I have a form based application that inputs values into various oracle tables, after it has done this I want to call a stored proceedure in Oracle which is already written to do more work on this...
0
by: pbaillard | last post by:
Here a sample to call a stored procedure with an Oracle Database. odc.Connection = m_cDb ' use an open connection to your database odc.CommandType = CommandType.StoredProcedure odc.CommandText =...
14
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.