Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle ASP
|
Oracle ASP Using ASP with Oracle databases. For Oracle discussions not specific to ASP, please see the Oracle forum. For more ASP discussions, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 22nd, 2006, 08:37 AM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default .Net reader with Oracle table function return type

Hi,
I have a problem to solve: with .Net i shoud call an Oracle function that return a table type. I tested my packege directly and it's right: it returns what i want. The c# method returns instead error.

Thank for all tips.

The package is like that.
Package:
CREATE OR REPLACE PACKAGE myPck AS
TYPE myRecord IS RECORD
(
IDPR NUMBER (12),
DESPR VARCHAR2 (40)
-- altri campi ...
);

TYPE myTable IS TABLE OF myRecord
INDEX BY BINARY_INTEGER;

FUNCTION Elabora(p_utente IN VARCHAR2)
RETURN myTable;

END myPck;

My class have a method like this
C# da applicativo .Net:
public List<Elenco> CallProc1(string idPr)
{
using (OracleConnection cn = new OracleConnection(this.ConnectionString))
{
List<Elenco> elenco = new List<Elenco>();
OracleCommand cmd = cn.CreateCommand();
cmd.CommandText = "myPck.Elabora";
cmd.CommandType = CommandType.StoredProcedure;

 cmd.Parameters.Add(new OracleParameter("IdPr", OracleType.VarChar)).Direction = ParameterDirection.Input;
cmd.Parameters[0].Value = idPr;

/* do something here ??? */

OracleDataReader reader;

cn.Open();

reader = command.ExecuteReader();
while (reader.Read())
{

/* Are right ??? */
Elenco ele = new Elenco();
ele.idPr = (int)reader["IDPR"];
ele.DesPr = reader["DESPR"].ToString();
elenco.Add(ele);
/**/

}
reader.Close();

}

return elenco;

}

 
Old July 24th, 2007, 06:45 AM
Authorized User
 
Join Date: Sep 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

An Oracle function can not be called like a stored procedure.
What you need to do is set the commandtype to text and use the following command text:
SELECT * FROM TABLE(function_name);

Greetz,

Geert

http://geertverhoeven.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
.Net reader with Oracle table function return type l.wolf ASP.NET 2.0 Basics 0 November 18th, 2006 12:36 PM
Calling Oracle function from Vb.net class monuindia2002 ADO.NET 1 August 4th, 2006 05:00 AM
Return TYPE TABLE to VB from Oracle muttleychess Pro VB Databases 3 August 2nd, 2006 03:28 PM
oracle data reader silvia C# 10 February 2nd, 2006 07:30 AM
could i join function(return table) with a table alyeng2000 SQL Server 2000 6 September 30th, 2004 07:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.