有没有办法在mybatis结果映射中指定一个字符串最多应包含20个字符?或者如何设置精度,如数字(4,2)?
例如,我有一个如下所示的结果图:
<resultMap id="IMap" type="com.optsol.beans.Item">
<result property="item_id" column="ITEM_ID" jdbcType="INTEGER" />
<result property="item_desc" column="ITEM_DESC" jdbcType="VARCHAR" />
<result property="min_qty" column="MIN_QTY" jdbcType="INTEGER" />
<result property="max_qty" column="MAX_QTY" jdbcType="INTEGER" />
<result property="abc" column="ABC" jdbcType="VARCHAR" />
<result property="item_weight" column="ITEM_WEIGHT" jdbcType="DOUBLE" />
<result property="size_cl" column="SIZE_CL" jdbcType="INTEGER" />
<result property="weight_class" column="WEIGHT_CLASS" jdbcType="INTEGER" />
<result property="exp_period" column="EXP_PERIOD" jdbcType="DOUBLE" />
<result property="code" column="CODE" jdbcType="VARCHAR" />
<result property="um" column="UM" jdbcType="VARCHAR" />
<result property="img" column="IMG" jdbcType="VARCHAR" />
<result property="conv_factor" column="CONV_FACTOR" jdbcType="DOUBLE" />
<result property="vol" column="VOL" jdbcType="INTEGER" />
<result property="info" column="INFO" jdbcType="VARCHAR" />
<result property="statist_report" column="STATIST_PERIOD"
jdbcType="INTEGER" />
<result property="pack_parent" column="PACK_PARENT" jdbcType="INTEGER" />
<result property="group_parent" column="GROUP_PARENT" jdbcType="INTEGER" />
<result property="order_full" column="ORDER_FULL" jdbcType="INTEGER" />
<result property="insDate" column="INSDATE" />
<result property="updDate" column="UPDDATE" />
<result property="insUser" column="INSUSER" jdbcType="VARCHAR" />
<result property="updUser" column="UPDUSER" jdbcType="VARCHAR" />
</resultMap>
我可以将int的位数限制为只有1,在浮点数上的“.”后面显示N个元素,或者将字符串大小限制为一定的数字吗?
我正在处理的视图具有以下列结构:
('ITEM_ID','NUMBER(10)','No',null,1,null,'NO','NO','NO');
('ITEM_DESC','VARCHAR2(80)','No',null,2,null,'NO','NO','NO');
('MIN_QTY','NUMBER(10)','Yes',null,3,null,'NO','NO','NO');
('MAX_QTY','NUMBER(10)','Yes',null,4,null,'NO','NO','NO');
('ABC','VARCHAR2(1)','No',null,5,null,'NO','NO','NO');
('ITEM_WEIGHT','NUMBER(10,3)','Yes',null,6,null,'NO','NO','NO');
('SIZE_CL','NUMBER(2)','Yes',null,7,null,'NO','NO','NO');
('WEIGHT_CLASS','NUMBER(2)','Yes',null,8,null,'NO','NO','NO');
('EXP_PERIOD','NUMBER(10,3)','Yes',null,9,null,'NO','NO','NO');
('CODE','VARCHAR2(20)','Yes',null,10,null,'NO','NO','NO');
('UM','VARCHAR2(15)','No',null,11,null,'NO','NO','NO');
('IMG','VARCHAR2(100)','Yes',null,12,null,'NO','NO','NO');
('CONV_FACTOR','NUMBER(10,4)','Yes',null,13,null,'NO','NO','NO');
('VOL','NUMBER(10)','Yes',null,14,null,'NO','NO','NO');
('INFO','VARCHAR2(100)','Yes',null,15,null,'NO','NO','NO');
('STATIST_PERIOD','NUMBER(5)','Yes',null,16,null,'NO','NO','NO');
('PACK_PARENT','NUMBER(10)','Yes',null,17,null,'NO','NO','NO');
('GROUP_PARENT','NUMBER(10)','Yes',null,18,null,'NO','NO','NO');
('ORDER_FULL','NUMBER(1)','No',null,19,null,'NO','NO','NO');
('INSDATE','DATE','No',null,20,null,'NO','NO','NO');
('UPDDATE','DATE','No',null,21,null,'NO','NO','NO');
('INSUSER','VARCHAR2(4000)','Yes',null,22,null,'NO','NO','NO');
('UPDUSER','VARCHAR2(4000)','Yes',null,23,null,'NO','NO','NO');
编辑1:每当我试图调用存储过程在此视图中添加新项时...我会得到这个错误:
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 2
我创建了一个用于测试的类,该类尝试调用add方法:
private ItemService iService = new ItemService(Item.class);
@Test
public void addProcTest() {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("p_item_desc", "theo3");
paramMap.put("p_min_qty", 1);
paramMap.put("p_max_qty", 2);
paramMap.put("p_abc", "A");
paramMap.put("p_item_weight", 2);
paramMap.put("p_size_cl", 1);
paramMap.put("p_weight_class", 1);
paramMap.put("p_exp_period", 2);
paramMap.put("p_code", "theo");
paramMap.put("p_um", "MP");
paramMap.put("p_conv_factor",2.0);
paramMap.put("p_vol", 2);
paramMap.put("p_info", "theo2");
paramMap.put("p_pack_parent", 105249);
paramMap.put("p_group_parent", 0);
paramMap.put("p_order_full", 0);
paramMap.put("p_statist_period", 0);
paramMap.put("p_do_it", 1);
iService.addItem(paramMap);
}
ItemMapper.xml中存储过程的调用:
<update id="addItem" parameterType="java.util.Map"
statementType="CALLABLE">
{call
SSLS_WMS.PKG_ITEM_ADMIN.PCREATEITEM(
#{p_item_desc,jdbcType=VARCHAR},
#{p_min_qty,jdbcType=INTEGER},
#{p_max_qty,jdbcType=INTEGER},
#{p_abc,jdbcType=VARCHAR},
#{p_item_weight,jdbcType=DOUBLE},
#{p_size_cl,jdbcType=INTEGER},
#{p_weight_class,jdbcType=INTEGER},
#{p_exp_period,jdbcType=DOUBLE},
#{p_code,jdbcType=VARCHAR},
#{p_um,jdbcType=VARCHAR},
#{p_conv_factor,jdbcType=DOUBLE},
#{p_vol,jdbcType=INTEGER},
#{p_info,jdbcType=VARCHAR},
#{p_pack_parent,jdbcType=INTEGER},
#{p_group_parent,jdbcType=INTEGER},
#{p_order_full,jdbcType=INTEGER},
#{p_statist_period,jdbcType=INTEGER},
#{p_do_it, jdbcType=INTEGER}
)
}
</update>
最后是存储过程:
PROCEDURE pCreateItem (
p_ITEM_DESC item.ITEM_DESC%type,
p_MIN_QTY item.MIN_QTY%type,
p_MAX_QTY item.MAX_QTY%type,
p_ABC item.ABC%type,
p_ITEM_WEIGHT item.ITEM_WEIGHT%type,
p_SIZE_CL item.SIZE_CL%type,
p_WEIGHT_CLASS item.WEIGHT_CLASS%type,
p_EXP_PERIOD item.EXP_PERIOD%type,
p_CODE item.CODE%type,
p_UM item_pack.UM%type,
p_IMG item_pack.IMG%type,
p_CONV_FACTOR item_pack.CONV_FACTOR%type,
p_VOL item_pack.VOL%type,
p_INFO item_pack.INFO%type,
p_PackParent item_pack.pack_id%type,
p_GroupParent item_pack.pack_id%type,
p_order_full item.order_full%type default 0,
p_statist_period item.STATIST_PERIOD%type default 3,
p_do_it PLS_INTEGER DEFAULT 1
);
您的问题是,您的过程有更多的参数,然后在MyBatis调用时传递给它,因此在缺少参数之后的任何时候,您都应该有ORA-06502:PL/SQL:numeric或value error
错误,因为以下参数在传递它的顺序上的类型不同。
您的程序包括:
(...)
p_EXP_PERIOD item.EXP_PERIOD%type,
p_CODE item.CODE%type,
p_UM item_pack.UM%type,
p_IMG item_pack.IMG%type,
p_CONV_FACTOR item_pack.CONV_FACTOR%type,
p_VOL item_pack.VOL%type,
(...)
你在MyBatis的电话,你正在做:
(...)
#{p_exp_period,jdbcType=DOUBLE},
#{p_code,jdbcType=VARCHAR},
#{p_um,jdbcType=VARCHAR},
#{p_conv_factor,jdbcType=DOUBLE},
#{p_vol,jdbcType=INTEGER},
#{p_info,jdbcType=VARCHAR},
(...)
所以在之后p_IMGitem_pack。IMG%type,
您没有传递任何未命中类型将导致您的错误。
在函数中,我在这一行上有ORA-06502错误: 我看这里没有任何转换问题/完全困惑/
我试图插入一个记录到oracle数据库使用一个过程。记录已插入,但出现异常。 将上述代码调用为: 以上代码调用以下过程; 执行语句时发生错误 组织。springframework。jdbc。BadSqlGrammarException:CallableStatementCallback;错误的SQL语法[{调用MYPROCEDURE(?,,,,,,,,,,,,,,,,,?)}];嵌套的异常是jav
下面是表上web方法适配器的错误,该适配器具有MIH_触发器。 (65000/6502)ORA-06502:PL/SQL:数字或值错误:字符到数字转换错误ORA-06512:在“B2B_OPS_BUILD_ADMIN.MIH_TRIGGER”第2行ORA-04088:执行触发器“B2B_OPS_BUILD_ADMIN”时出错。米尤触发器' 下面是MIH_TRIGGER引用,每当更新OFFSET列时
我在执行触发器时遇到以下错误: 请说明问题的原因。 编辑 数据类型:
我以不同的方式尝试了以下代码,比如去掉while或if,但是当我把它们放在一起(if和while)时,我总是在最后得到错误。。。 错误: 通过将变量“a”的声明方式更改为: *注意,这里的显著变化是使用VARCHAR2而不是CHAR(不是更大的长度)。根据@user272735的回答,这是关键。
我得到了 ORA-06502:PL/SQL:以下代码中出现数值或值错误: