https://bugzilla.novell.com/show_bug.cgi?id=424915
Summary: Oracle - stored procedure returning string padded
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: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
Found By: Development
When a stored procedure returns a value through an OUT string parameter, and
the size is set after the out parameter is constructed - the string returned
is padded to the specified size. (and shouldn't be)
-----------------------------------------------------------
With the following pl/sql stored procedure:
-----------------------------------------------------------
----------------------------------------------------------------------
-- GetProviderDesc
-- Returns the textual description for the provider with the given ID
----------------------------------------------------------------------
PROCEDURE GetProviderDesc
(
providerID IN PROVIDER.PROVIDER_ID%type,
providerDesc OUT PROVIDER.PROVIDER_DESC%type -- which is NVarChar
)
AS
BEGIN
SELECT PROVIDER.PROVIDER_DESC INTO providerDesc
FROM PROVIDER
WHERE PROVIDER.PROVIDER_ID = providerID;
END; -- PROCEDURE ListAuditSamples
-----------------------------------------------------------
using the following code:
-----------------------------------------------------------
System.Data.OracleClient.OracleParameter providerDesc = new
System.Data.OracleClient.OracleParameter();
providerDesc.ParameterName = "providerDesc";
providerDesc.OracleType =
System.Data.OracleClient.OracleType.NVarChar;
providerDesc.Direction = System.Data.ParameterDirection.Output;
providerDesc.Value = string.Empty;
// if size is not set, and even if size is set in parameter
consstructor,exception 'Size must be set.' is thrown
// at System.Data.OracleClient.OracleParameter.AssertSizeIsSet ()
[0x00000]
// at System.Data.OracleClient.OracleParameter.Bind
(System.Data.OracleClient.Oci.OciStatementHandle statement,
System.Data.OracleClient.OracleConnection con, UInt32 pos) [0x00000]
// at (wrapper remoting-invoke-with-check)
System.Data.OracleClient.OracleParameter:Bind
(System.Data.OracleClient.Oci.OciStatementHandle,System.Data.OracleClient.OracleConnection,uint)
// at System.Data.OracleClient.OracleCommand.BindParameters
(System.Data.OracleClient.Oci.OciStatementHandle statement) [0x00000]
// at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal
(System.Data.OracleClient.Oci.OciStatementHandle statement, Boolean
useAutoCommit) [0x00000]
// at System.Data.OracleClient.OracleCommand.ExecuteNonQuery ()
[0x00000]
// i.e., Size must be set independently from OracleParameter constructor
providerDesc.Size = 256;
ExecuteStoredProcedure ( PKG_NAME + ".GetProviderDesc", //string
procName,
new
System.Data.OracleClient.OracleParameter[] {
CreateNumberParam("providerID", providerID),
providerDesc
} );
System.Console.WriteLine("providerDesc = '" + providerDesc.Value + "'");
-----------------------------------------------------------
yields the following output:
-----------------------------------------------------------
providerDesc = 'Groove Addicts
'
-----------------------------------------------------------
If the above reads strangely, essentially, the oracle driver
has inserted whitespace for up to the number of characters
specified in the OracleParameter's Size member. Preferably
the string returned should not be padded at all.
-----------------------------------------------------------
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs