From: Anupam M. (JIRA) <nh...@gm...> - 2011-04-26 05:30:55
|
Problem in passing user defined data type to stored procedure as parameter -------------------------------------------------------------------------- Key: NH-2675 URL: http://216.121.112.228/browse/NH-2675 Project: NHibernate Issue Type: Bug Components: DataProviders / Dialects Affects Versions: 3.0.0.GA Reporter: Anupam Mishra HI I am using NHibernate30.As per our requirement we need to send User Defined data type(i.e Custom Data Type ) as a parameter to stored procedure.With ADO.net this is working following are my Stored Procedure,Type and domain Object . *************Store Procedure**************** create or replace PROCEDURE odp_varray_sample_proc(p_cursor out SYS_REFCURSOR,param IN odp_varray_sample_type) IS BEGIN FOR counter IN 1..3 LOOP insert into temp_tran (emp_id, emp_name, emp_password, team_associated_with,IS_CAPTAIN,NO_OF_MOM,BALANCE) SELECT EMP_ID,EMP_NAME,EMP_PASSWORD,TEAM_ASSOCIATED_WITH, IS_CAPTAIN,NO_OF_MOM,BALANCE FROM employee WHERE EMP_ID=param(counter); end LOOP; open p_cursor for select * from temp_tran; delete from temp_tran; END odp_varray_sample_proc; *****End Stored Procedure********************** **TYpe in Database Oracle*********** create or replace type odp_varray_sample_type as varray(3000) of number; ****End Type in Database Oracle****** *****Domain Object***************************** public class odp_varray_sample_type : NHibernate.Type.ImmutableType { public Int64[] int_array; public odp_varray_sample_type() : base(new NHibernate.SqlTypes.SqlType(System.Data.DbType.Object)) { } public odp_varray_sample_type(Int64[] array) : base(new NHibernate.SqlTypes.SqlType(System.Data.DbType.Object)) { this.int_array = array; } public override object FromStringValue(string xml) { return xml.ToString(); } public override object Get(System.Data.IDataReader rs, string name) { return name.ToString(); } public override object Get(System.Data.IDataReader rs, int index) { return index.ToString(); } public override void Set(System.Data.IDbCommand cmd, object value, int index) { OracleCommand orclCmd = (OracleCommand)cmd; orclCmd.Parameters[index].OracleDbType = OracleDbType.Int64; orclCmd.Parameters[index].CollectionType = OracleCollectionType.PLSQLAssociativeArray; orclCmd.Parameters[index].Value = value; } public override string ToString(object val) { return val.ToString(); } public override string Name { get { return Name; } } public override Type ReturnedClass { get { return this.GetType(); } } } *****END Domain Object***************************** Error coming as Wrong number of argument or type.Please help. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-04-26 11:58:54
|
[ http://216.121.112.228/browse/NH-2675?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo closed NH-2675. --------------------------- Resolution: Not an Issue This is not the place to know "how" or ask for help. Please send your questions to the nhusers group. > Problem in passing user defined data type to stored procedure as parameter > -------------------------------------------------------------------------- > > Key: NH-2675 > URL: http://216.121.112.228/browse/NH-2675 > Project: NHibernate > Issue Type: Bug > Components: DataProviders / Dialects > Affects Versions: 3.0.0.GA > Reporter: Anupam Mishra > > HI I am using NHibernate30.As per our requirement we need to send User Defined data type(i.e Custom Data Type ) as a parameter to stored procedure.With ADO.net this is working > following are my Stored Procedure,Type and domain Object . > > *************Store Procedure**************** > create or replace > PROCEDURE odp_varray_sample_proc(p_cursor out SYS_REFCURSOR,param IN odp_varray_sample_type) > IS > BEGIN > FOR > counter IN 1..3 > LOOP > insert into temp_tran (emp_id, emp_name, emp_password, team_associated_with,IS_CAPTAIN,NO_OF_MOM,BALANCE) > SELECT EMP_ID,EMP_NAME,EMP_PASSWORD,TEAM_ASSOCIATED_WITH, > IS_CAPTAIN,NO_OF_MOM,BALANCE FROM employee WHERE EMP_ID=param(counter); > end LOOP; > open p_cursor for select * from temp_tran; > delete from temp_tran; > END odp_varray_sample_proc; > *****End Stored Procedure********************** > **TYpe in Database Oracle*********** > create or replace type odp_varray_sample_type as varray(3000) of number; > ****End Type in Database Oracle****** > *****Domain Object***************************** > public class odp_varray_sample_type : NHibernate.Type.ImmutableType > { > public Int64[] int_array; > public odp_varray_sample_type() > : base(new NHibernate.SqlTypes.SqlType(System.Data.DbType.Object)) > { > } > public odp_varray_sample_type(Int64[] array) > : base(new NHibernate.SqlTypes.SqlType(System.Data.DbType.Object)) > { > this.int_array = array; > } > public override object FromStringValue(string xml) > { > return xml.ToString(); > } > public override object Get(System.Data.IDataReader rs, string name) > { > return name.ToString(); > } > public override object Get(System.Data.IDataReader rs, int index) > { > return index.ToString(); > } > public override void Set(System.Data.IDbCommand cmd, object value, int index) > { > OracleCommand orclCmd = (OracleCommand)cmd; > > orclCmd.Parameters[index].OracleDbType > = OracleDbType.Int64; > orclCmd.Parameters[index].CollectionType > = OracleCollectionType.PLSQLAssociativeArray; > orclCmd.Parameters[index].Value = value; > } > public override string ToString(object val) > { > return val.ToString(); > } > public override string Name > { > get > { > return Name; > } > } > public override Type ReturnedClass > { > get > { > return this.GetType(); > } > } > } > *****END Domain Object***************************** > Error coming as > Wrong number of argument or type.Please help. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |