CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.microsoft_application_blocks Tags:
Item Type: NewsGroup Date Entered: 11/13/2007 9:05:22 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 10 Views: 88 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
11 Items, 1 Pages 1 |< << Go >> >|
mickeyfinn
Asp.Net User
MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/13/2007 9:05:22 PM

0/0

 I've searched Google for hours and haven't found a clear answer so decided to prompt a post in hopes of finding a better result.  I've got some wrapper code that calls the Ent. Library DAAB for Oracle.  Essentially I pass in the Stored Proc name, data access type (SQL or Proc), and database type (Oracle, SQL, DB2).  Based on which items get passed it calls ends up calling ExecuteScalar(dbCommandWrapper, dbIns, dbIns2).  Which then steps into Ent. Library to call Oracle cs classes associated to calling the apprpriate execution. 

I've test the Procedure directly against Oracle with no issues.  I've test the wrapper classes by changing the procedure into direct SQL and everything works fine.  However once I use a procedure passed to ExecuteScalar against Oracle, it always returns the object as 'Nothing'.  The ExecuteScalar works for SQL Server and DB2 when calling a procedure but not Oracle. 

I read one article that indicated that this is because DAAB doesn't allow out parms with ExecuteScalar and that Oracle requires return values to be passed as Out parameters.  Then it goes on to say that a person would need to do all transactions using ExecuteNonQuery instead of ExecuteScalar.  I can get ExecuteNonQuery to work, but not ExecuteScalar.  I just want to confirm Oracle's relationship with MS DAAB and the procedure regarding returns before doing away with using scalar anywhere.  I also am wondering if I should take the time to rewrite the Ent. Lib. to use the ODP.NET connections instead of Microsoft's and if by doing this ExecuteScalar becomes available again.

 

Suggestions?

rmaiya
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/14/2007 4:50:11 AM

0/0

There is some bug in that. It never worked for me.. follow this http://forums.asp.net/t/1170399.aspx , I made a work around, instead of using executeScalar, I created RefCursor in SP and used ExecuteReader(). Hope this helps


Raghu
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
mickeyfinn
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/14/2007 1:40:28 PM

0/0

thanks for the quick response. I'll check out the link you included.  I think I already saw that link but it didn't have and actual final fix for ExecuteScalar which would make sense since you are using nonquery/reader instead.

 

Does anyone know if this is a legitamite problem in 1.1 and is resolved in later framework versions of the Ent. Lib. or should I plan to use ExecuteReader/ExecuteNonQuery for these types of efforts going forward?

 

Thanks again.

Triax
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/15/2007 12:38:43 AM

0/0

Can you post an example proc? I can see if it works in the EntLib 3.1, and maybe get you a solution for 1.1. 


Matthew Noonan

Noonan Consulting Inc.
EasyObjects.NET - The O/RM architecture for the Enterprise Library
mickeyfinn
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/15/2007 2:08:57 PM

0/0

CREATE OR REPLACE PACKAGE BODY SCHEMAOWNER.PACKAGENAME AS

PROCEDURE SP_PROC1 (xID IN VARCHAR2)
IS
placeholder INTEGER;
BEGIN
SELECT DISTINCT 1 INTO placeholder
FROM
    TABLENAME1 A, TABLENAME2 A1
WHERE
    A.ID=xID
    AND
    A.ID=A1.ID;
    
END SP_PROC1;


END PACKAGENAME;

Triax
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/15/2007 11:35:47 PM

0/0

I Googled a lot for this, as I'm sure you did, and found that nobody has come up with a really good answer. You are correct that ExecuteScalar does not work as advertised with stored procedures. However, it does work with a plain SQL string. So it seems you have two possible solutions. Either don't use stored procs when using ExecuteScalar, or you'll have to go with the following (which is the only way I could get it to work):

static void Main(string[] args)
{
    try
    {
        object obj = TestDynamicSqlScalar();
        string s = obj.ToString();
        Console.WriteLine("Dynamic SQL scalar: {0}", s);

        obj = TestStoredProcScalar();
        s = obj.ToString();
        Console.WriteLine("Stored proc scalar: {0}", s);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        Console.WriteLine();
        Console.WriteLine(ex.StackTrace);
    }
    finally
    {
        Console.WriteLine();
        Console.WriteLine("Press <ENTER> to continue...");
        Console.ReadLine();
    }
}

public static object TestDynamicSqlScalar()
{
    //  Create the Database object, using the default database service. The
    //  default database service is determined through configuration.
    Database db = DatabaseFactory.CreateDatabase();

    string sqlCommand = "SELECT COUNT(*) FROM test";
    DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

    return db.ExecuteScalar(dbCommand);
}

public static object TestStoredProcScalar()
{
    //  Create the Database object, using the default database service. The
    //  default database service is determined through configuration.
    Database db = DatabaseFactory.CreateDatabase();

    string sqlCommand = "testscalar";
    DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

    db.AddOutParameter(dbCommand, "rc", DbType.Int32, 0);

    db.ExecuteNonQuery(dbCommand);

    return db.GetParameterValue(dbCommand, "rc");
}

And the stored proc:

create or replace procedure testscalar (
  rc OUT INTEGER
  )
AS
begin
  SELECT COUNT(*) INTO rc FROM test;
end;
 

Hope that helps. 


Matthew Noonan

Noonan Consulting Inc.
EasyObjects.NET - The O/RM architecture for the Enterprise Library
rmaiya
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/16/2007 12:36:40 AM

0/0

Same problem I encountered, I ended up doing ExecuteReader, it works like a champ and the same I suggested in my previous post :) 


Raghu
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
Triax
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/16/2007 3:31:07 AM

0/0

Did you have to setup a REF CURSOR in order to do the reader? If so, then the single parameter may be less overhead. It probably depends on the individual situation. 


Matthew Noonan

Noonan Consulting Inc.
EasyObjects.NET - The O/RM architecture for the Enterprise Library
Triax
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/16/2007 4:39:55 AM

0/0

I was curious, so I modified my code to test both the parameter solution and the reader solution. It turns out, there is some overhead with the reader.

Total parameter time: 21.5936117999998
Total reader time:    35.6872715999988

Press <ENTER> to continue...

But that is after 10,000 straight calls. So if you are interested in the absolute peak performance, then the parameter method is the way to go. But for most other uses, the reader is probably just fine. 


Matthew Noonan

Noonan Consulting Inc.
EasyObjects.NET - The O/RM architecture for the Enterprise Library
mickeyfinn
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/16/2007 2:28:38 PM

0/0

Thanks everyone for their responses.  I'm now using ExecuteNonQuery with a single out parameter.  It works fine as long as I put exception blocks in my SQL Procedure for 'No Data Returned'.

 http://msdn2.microsoft.com/en-us/library/ms971506.aspx It appears that according to the link above, this is a none microsfot thing with regard to ExecuteScalar and Oracle Procs due to no out parameters being allowed.
Triax
Asp.Net User
Re: MS DAAB For Oracle - ExecuteScalar with Stored Procedure11/16/2007 2:50:30 PM

0/0

That's an interesting link. Did you read the section on "Accessing Return Values"?

http://msdn2.microsoft.com/en-us/library/ms971506.aspx#msdnorsps_topic5

That might be another way to go. It's roughly the same as the parameter approach already discussed, though.


Matthew Noonan

Noonan Consulting Inc.
EasyObjects.NET - The O/RM architecture for the Enterprise Library
11 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
MS DAAB For Oracle - ExecuteScalar with Stored Procedure - ASP.NET ... MS DAAB For Oracle - ExecuteScalar with Stored Procedure. Last post 11-16-2007 9 :50 AM by Triax. 10 replies. Sort Posts: ...
OracleCommand.ExecuteScalar() - ASP.NET Forums I am using MS DAAB For Oracle [Nile 3.0], And I use stored procedures to insert records into Oracle DB. After inserting the new record I ...
Design Resilient Business Objects with MS DAAB Even so, you can make your DAAB modifications "fake" stored procedures in ... for that in the exception catch handlers for ExecuteReader and ExecuteScalar . ...
Simplify .NET SQL queries with the DAAB - Program - SQL Server ... Microsoft's Data Access Application Block (DAAB) makes connecting . ... Stored procedures are default for the components, so you can ignore the type ...
Data Points: The Enterprise Library Data Access Application Block ... Sometimes all that is needed from a stored procedure or an inline SQL statement is a single value. In this case using the Database.ExecuteScalar method is ...
ASP.NET.4GuysFromRolla.com: Working with the Enterprise Library's ... Mar 9, 2005 ... Accessing Data with the Data Access Application Block (DAAB) ... parameterized stored procedures, and the use of transactions. ...
InformIT: .NET Reference Guide > The Data Access Application Block Use only stored procedures. This applies to any data access application, regardless of ... As of yet, there is no DAAB for DB2, Oracle, Microsoft Access, ...
Get Started with the Enterprise Library Data Access Application ... I want to know how to use Ent.Library(DAAB) for Oracle coz lot of online .... Most MS DBA's seem to favor stored procedures and most Oracle DBA's seem to ...
DotNetBips.com :: Blossom your .NET skills Many times we use databases other that SQL Server (MS-Access/Oracle). ... MS- DAAB uses ParamArray mechanism to pass query or stored procedure parameters. ...
CodeProject: C# Code Generator for Stored Procedures. Free source ... This stored procedure will generate all the C# code for calling any Stored Procedure; ... Anybody got a vesion of the code generator for Jan 2006 MS DAAB. ...




Search This Site:










loggin in portals automatically.

how to create a forum using dnn 4.0.2?

re-authenticating a user even with the authentication cookie set

editmodule

can't run .asmx files?

tool to convert mdf to sql?

web page looks great in ie 7 (no supprise) but is meesed up in firefox.

why does menu control not show subnavs unless page refreshed?

skinning question

where can i donwload vs 2005 team system

treemenu, hyperlink & sitemap

database problem i think :)

skin upload - file manager (.zip) vs. ftp (.aspx, etc)

c# equivalent of addressof

restricting users based on roles

3.0.13 issue?? visible by administrators only

can we extend the precompiled & deployed application in asp.net

nagivation issue with gallery add-in for dnn3

grouping members

how to add a user-control to a page?

web designer & asp.net configuration tool error

password expiry

visual studio crashes

what is with the naming conventions of user controls in vs2005!

replacing web.config connectionstring user id and password

forms processing

where can i get download the ibuystore code with accesss and vb?

upgrade issues 2.0.4 to 2.1.2

request is not available in this context

tabstrip && internet explorer 7

 
All Times Are GMT