Hello,
I'm working on an
asp.net project which connects to Oracle database.
I plan to use the mybatisnet to execute Oracle store procedure, the store procedure has some custom type parameters:
CREATE OR REPLACE PROCEDURE SABAINTG.sp_hp_wep_stg_cert_inbound (
p_objarray_in IN typ_hp_wep_stg_objarr,
p_table IN VARCHAR2,
p_columns IN VARCHAR2,
p_flag_truncate IN NUMBER,
p_flag_staging IN NUMBER,
p_flag_validate IN NUMBER,
p_flag_process IN NUMBER,
p_errtrack_id IN NUMBER,
p_track_id IN NUMBER,
p_result OUT NUMBER,
p_tot_rec OUT NUMBER,
p_ins_rec OUT NUMBER,
p_upd_rec OUT NUMBER,
p_err_rec OUT NUMBER,
p_err_message OUT VARCHAR2,
p_err_cursor OUT TYPES.cursor_type
)
AS...
------------------------------------------
CREATE OR REPLACE TYPE SABAINTG."TYP_HP_WEP_STG_OBJARR" IS VARRAY(20000) OF TYP_HP_WEP_STG_OBJ;
------------------------------------------
CREATE OR REPLACE TYPE SABAINTG."TYP_HP_WEP_STG_OBJ" AS OBJECT(COL1 VARCHAR2(2000),
COL2 VARCHAR2(2000),
COL3 VARCHAR2(2000),
COL4 VARCHAR2(2000),
COL5 VARCHAR2(2000),
COL6 VARCHAR2(2000),
....,
COL99 VARCHAR2(2000),
COL100 VARCHAR2(2000));
/
in mybatisnet config parameter section:
<parameterMap id="insertCertificationDetailsParam">
<parameter property="objArray" typeHandler="CustomType" dbType="TYP_HP_WEP_STG_OBJARR" direction="Input"/>
<parameter property="table" dbType="VARCHAR2" direction="Input"/>
<parameter property="columns" dbType="VARCHAR2" direction="Input"/>
<parameter property="truncate" dbType="NUMBER" direction="Input"/>
<parameter property="staging" dbType="NUMBER" direction="Input"/>
<parameter property="validation" dbType="NUMBER" direction="Input"/>
<parameter property="process" dbType="NUMBER" direction="Input"/>
<parameter property="errTrackId" dbType="NUMBER" direction="Input"/>
<parameter property="trackId" dbType="NUMBER" direction="Input"/>
<parameter property="returnCode" dbType="NUMBER" direction="Output"/>
<parameter property="totalRecord" dbType="NUMBER" direction="Output"/>
<parameter property="insertedRecord" dbType="NUMBER" direction="Output"/>
<parameter property="updatedRecord" dbType="NUMBER" direction="Output"/>
<parameter property="errorRecord" dbType="NUMBER" direction="Output"/>
<parameter property="returnMessage" dbType="VARCHAR2" direction="Output"/>
<parameter property="resultSet" dbType="Cursor" direction="Output"/>
</parameterMap>
--------------------------------------------
<alias>
<typeAlias alias="CustomType" type="WebApplication1.HandleTypes.CertificationServicestg,WebApplication1"/>
</alias>
---------------------------------------------
in my .net type handle code:
public void SetParameter(IParameterSetter setter, object parameter)
{
STG[] arrObj = (STG[])parameter;
setter.Value = arrObj;
}
I added the "Oracle.DataAccess.dll" file into the project:
using Oracle.DataAccess.Types;
public class STG : IOracleCustomType
{
private string col1;
[OracleObjectMappingAttribute("COL1")]
public string COL1 { get { return col1; } set { col1 = value; } }
private string col2;
[OracleObjectMappingAttribute("COL2")]
public string COL2 { get { return col2; } set { col2 = value; } }
private string col3;
[OracleObjectMappingAttribute("COL3")]
public string COL3 { get { return col3; } set { col3 = value; } }
............
private string col100;
[OracleObjectMappingAttribute("COL100")]
public string COL100 { get { return col100; } set { col100 = value; } }
}
then I start to excute the store procedure:
STG[] certDos = new STG[dss.Tables[0].Rows.Count];
Hashtable map = new Hashtable();
map.Add("objArray", certDos);
map.Add("table", strTableName);
map.Add("columns", columnNames);
map.Add("truncate", truncateFlg);
map.Add("staging", stgFlg);
map.Add("validation", validationFlg);
map.Add("process", processFlag);
map.Add("errTrackId", err_trackId);
map.Add("trackId", trackId);
ISqlMapper iSqlMapper = Mapper.Instance();
if (iSqlMapper != null)
{
iSqlMapper.Insert("CertificationService_InsertCertificationDetails", map); //error comes: Failed to convert parameter value from a STG[] to a String.
}
but I got an error :Failed to convert parameter value from a STG[] to a String.
so how can I passing .net object array value to mapping the custom type parameter in oracle store procedure?
if anybody knows, please tell me, thanks a lot:)
Best Regards
Eric