mail-archives/mono-bugs/2008-September/079129.html

309 строки
7.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 424897] New: Assignment to OracleLob throws exception
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20424897%5D%20New%3A%20Assignment%20to%20OracleLob%20throws%0A%09exception&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="079133.html">
<LINK REL="Next" HREF="079509.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 424897] New: Assignment to OracleLob throws exception</H1>
<B>bugzilla_noreply at novell.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20424897%5D%20New%3A%20Assignment%20to%20OracleLob%20throws%0A%09exception&In-Reply-To="
TITLE="[Mono-bugs] [Bug 424897] New: Assignment to OracleLob throws exception">bugzilla_noreply at novell.com
</A><BR>
<I>Tue Sep 9 14:58:38 EDT 2008</I>
<P><UL>
<LI>Previous message: <A HREF="079133.html">[Mono-bugs] [Bug 424896] SLE ignores type argument constraints
</A></li>
<LI>Next message: <A HREF="079509.html">[Mono-bugs] [Bug 424897] Assignment to OracleLob throws exception
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#79129">[ date ]</a>
<a href="thread.html#79129">[ thread ]</a>
<a href="subject.html#79129">[ subject ]</a>
<a href="author.html#79129">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE><A HREF="https://bugzilla.novell.com/show_bug.cgi?id=424897">https://bugzilla.novell.com/show_bug.cgi?id=424897</A>
Summary: Assignment to OracleLob throws exception
Product: Mono: Class Libraries
Version: 2.0
Platform: x86-64
OS/Version: SLES 10
Status: NEW
Severity: Blocker
Priority: P5 - None
Component: Sys.Data
AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">bnc-blr-team-mono at forge.provo.novell.com</A>
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">webservices at landmarkdigital.com</A>
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
Found By: Development
In the example below, when the assignment is made to p1.Value, an exception is
thrown. This code works in .NET 2.0. There appears to be no way to create a
blob oracle input paramter for a stored procedure call.
using System;
using System.Data;
using System.Data.OracleClient;
namespace BlobTest
{
class MainClass
{
public static void Main(string[] args)
{
checkTNS();
InsertBlob();
}
public static void checkTNS()
{
string tnsAdmin =
System.Environment.GetEnvironmentVariable(&quot;TNS_ADMIN&quot;);
if ( (tnsAdmin == null)
|| (string.Empty.Equals(tnsAdmin)) )
{
System.Environment.SetEnvironmentVariable(&quot;TNS_ADMIN&quot;,
&quot;/home/tns&quot;);
}
}
public static decimal InsertBlob()
{
byte[] ByteArray = new byte[2000];
decimal retVal = -1;
string sproc = &quot;MyPackage&quot; + &quot;.InsertBlob&quot;;
OracleCommand cmd = new OracleCommand();
cmd.CommandText = sproc;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = new OracleConnection(@&quot;Data Source=mysource;User
Id=myuser;Password=mypass&quot;);
cmd.Connection.Open();
cmd.Transaction = cmd.Connection.BeginTransaction();
try
{
OracleParameter p1 = new OracleParameter(&quot;i_Sig_File&quot;,
OracleType.Blob);
p1.Direction = ParameterDirection.Input;
//EXCEPTION thrown here
p1.Value = GetOracleLob(cmd.Transaction, ByteArray);
cmd.Parameters.Add(p1);
cmd.ExecuteNonQuery();
cmd.Transaction.Commit();
}
catch(Exception ex)
{
Console.WriteLine(&quot;I exploded:&quot; + ex.ToString());
cmd.Transaction.Rollback();
}
return retVal;
}
private static OracleLob GetOracleLob(OracleTransaction transaction,
byte[] blob)
{
string BLOB_CREATE = &quot;DECLARE dpBlob BLOB; BEGIN &quot;
+ &quot;DBMS_LOB.CREATETEMPORARY(dpBlob , False, 0); :tempBlob :=
dpBlob; &quot;
+ &quot;END;&quot;;
OracleLob tempLob = OracleLob.Null;
if (blob != null)
{
// Create a new command using the same connection
OracleCommand command = transaction.Connection.CreateCommand();
// Assign the transaction to the command
command.Transaction = transaction;
// Create blob storage on the Oracle server
command.CommandText = BLOB_CREATE;
// Add a new output paramter to accept the blob storage
reference
command.Parameters.Add(
new OracleParameter(&quot;tempBlob&quot;, OracleType.Blob)).Direction =
ParameterDirection.Output;
// Fire as your guns bear...
command.ExecuteNonQuery();
// Retrieve the blob stream from the OracleLob parameter
tempLob = (OracleLob)command.Parameters[0].Value;
// Prevent server side events from firing while we write to the
stream
tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);
// Write bytes to the stream
tempLob.Write(blob, 0, blob.Length);
// Resume firing server events
tempLob.EndBatch();
}
return tempLob;
}
}
}
--
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
------- You are receiving this mail because: -------
You are the QA contact for the bug.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="079133.html">[Mono-bugs] [Bug 424896] SLE ignores type argument constraints
</A></li>
<LI>Next message: <A HREF="079509.html">[Mono-bugs] [Bug 424897] Assignment to OracleLob throws exception
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#79129">[ date ]</a>
<a href="thread.html#79129">[ thread ]</a>
<a href="subject.html#79129">[ subject ]</a>
<a href="author.html#79129">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>