I am writing a web service in C# that connects to an Oracle database via OleDb and wish for the service to return a dataset for use by a client application. I have achieved this using dynamic sql but now there is a requirement to use stored procedures instead, thus calling these from the web service.
As I am using OleDb to connect to the Oracle database, what method is the best way forward here to achieve the results I am after, please? I have been reading about the use of REF CURSOR but I'm not sure if this is the best approach.
Here is an example of one of the stored procedures I am using:
Expand|Select|Wrap|Line Numbers
- CREATE OR REPLACE PROCEDURE SADAS_MANAGER.NLPGAddSearchOne
- (
- p_postcode in varchar2,
- p_paostartnumber in int,
- fullAdd out varchar2
- )
- IS
- BEGIN
- select full_address into fullAdd from nlpg_uk where POST_CODE = p_postcode AND PAO_START_NUMBER = p_paostartnumber
- ORDER BY ABS(PAO_START_NUMBER) ASC
- ;
- END;
- /
Expand|Select|Wrap|Line Numbers
- [WebMethod (Description = "Return address details based on two parameters (string, int) corresponding to post code and house number and run type = NLPG")]
- public DataSet NLPGAddressSearchOne(string whereValue1, int whereValue2)
- {
- OleDbConnection conn = GetConn();
- conn.Open();
- OleDbCommand sComm = new OleDbCommand("NLPGAddSearchOne", conn);
- sComm.CommandType = CommandType.StoredProcedure;
- sComm.Parameters.Add("p_postcode", OleDbType.Char).Value = whereValue1;
- sComm.Parameters.Add("p_paostartnumber", OleDbType.Integer).Value = whereValue2;
- OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sComm);
- DataSet addDataSet = new DataSet();
- dataAdapter.Fill(addDataSet);
- return addDataSet;
- }
Thank you.
M :)