Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle ASP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 22nd, 2006, 08:37 AM
Registered User
 
Join Date: Nov 2006
Location: , , Italy.
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;

}

  #2 (permalink)  
Old July 24th, 2007, 06:45 AM
Authorized User
 
Join Date: Sep 2004
Location: Edegem, Antwerpen, Belgium.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.