嗯 调试看变量的值是正常的。试过直接把这个参数值写死,像是where a.fnumber='调试时看到的变量值' 可以正常执行。 看看变量类型之类的,还有就是长度之类的两个参数的类型对应想要查询的字段在表中的类型。 在这之前有试过NVarchar2(XX)和varchar2(XX)都不行。 测试用转型解决,测试代码如下: create or replace procedure update_ProjId(contNum t_sd_salecontract.fnumber%type,proID t_sd_salecontract.fprojectitemid%type) as --V_Con VARCHAR2(15); V_Order VARCHAR2(15); V_Bill VARCHAR2(15); V_ContNum NVARCHAR2(12); beginV_ContNum := ContNum; --类型转换--select a.fnumber into V_Con ,b.fnumber into V_Order ,c.fnumber into V_Bill select b.fnumber into V_Order from t_sd_salecontract a left join t_sd_saleorder b on a.fnumber=b.fcontractnumber where a.fnumber=V_ContNum;select c.fnumber into V_Bill from t_sd_salecontract a left join t_ar_otherbill c on a.fnumber=c.fexcontractnumber where a.fnumber=V_ContNum;update t_sd_saleorder a set a.cfprojectitemid=proID where a.fnumber=V_Order; update t_ar_otherbill a set a.cfprojectitemid=proID where a.fnumber=V_Bill; update t_sd_salecontract a set a.fprojectitemid=proID where a.fnumber=contNum; commit;end update_ProjId; 结果是同样的报错。
select b.fnumber into V_Orderfrom t_sd_salecontract a left join t_sd_saleorder b on a.fnumber=b.fcontractnumber where to_char(a.fnumber)=to_char(V_ContNum);
看看变量类型之类的,还有就是长度之类的
看看变量类型之类的,还有就是长度之类的两个参数的类型对应想要查询的字段在表中的类型。
在这之前有试过NVarchar2(XX)和varchar2(XX)都不行。
测试用转型解决,测试代码如下:
create or replace procedure update_ProjId(contNum t_sd_salecontract.fnumber%type,proID t_sd_salecontract.fprojectitemid%type) as
--V_Con VARCHAR2(15);
V_Order VARCHAR2(15);
V_Bill VARCHAR2(15);
V_ContNum NVARCHAR2(12);
beginV_ContNum := ContNum; --类型转换--select a.fnumber into V_Con ,b.fnumber into V_Order ,c.fnumber into V_Bill select b.fnumber into V_Order
from t_sd_salecontract a left join t_sd_saleorder b on a.fnumber=b.fcontractnumber
where a.fnumber=V_ContNum;select c.fnumber into V_Bill
from t_sd_salecontract a left join t_ar_otherbill c on a.fnumber=c.fexcontractnumber
where a.fnumber=V_ContNum;update t_sd_saleorder a set a.cfprojectitemid=proID
where a.fnumber=V_Order;
update t_ar_otherbill a set a.cfprojectitemid=proID
where a.fnumber=V_Bill;
update t_sd_salecontract a set a.fprojectitemid=proID
where a.fnumber=contNum;
commit;end update_ProjId;
结果是同样的报错。
看看变量类型之类的,还有就是长度之类的
nvarchar2的需要设成长度为12才能接收长度为10的字符串,会有影响吗?
测试过重新赋值,代码见7楼。值可以正常赋给v_contnum,但查询时仍报错。
测试过重新赋值,代码见7楼。值可以正常赋给v_contnum,但查询时仍报错。
我想的是要不你传入参数的时候变量类型直接写成和下面的类型一样嘛,这样就不用再进行类型转换。
比如: contNum t_sd_salecontract.fnumber%type -->contNum varchar2
然后再where中直接用这个参数
测试过重新赋值,代码见7楼。值可以正常赋给v_contnum,但查询时仍报错。
能传过来 还有错 my god! 那你试试10楼的
为什么要设计字段是nvarchar的呀。还有人家定义80,你怎么就用12来接呀。不过这个不是这个问题的所在