这是我的SQL
;
select a.hesap_no,
a.teklif_no1 || '/' || a.teklif_no2 as teklif,
a.mus_k_isim as musteri,
b.marka,
c.sasi_no,
c.sasi_durum,
d.tas_mar,
nvl(risk_sasi(a.teklif_no1, a.teklif_no2, c.urun_sira_no, c.sira_no), 0) as risk,
nvl(mv_sasi(a.teklif_no1, a.teklif_no2, c.sira_no, c.urun_sira_no, sysdate), 0) as mv
from s_teklif a,
s_urun b,
s_urun_detay c,
koc_ktmar_pr d
where a.teklif_no1 || a.teklif_no2 = b.teklif_no1 || b.teklif_no2
这是我的MV_SASI
功能;
create or replace
FUNCTION MV_SASI
(
TEK1 IN VARCHAR2,
TEK2 IN NUMBER,
SIRA IN NUMBER,
USIRA IN NUMBER,
DT IN DATE
)
RETURN NUMBER IS MV number;
fat number;
adet number;
pd number;
pds number;
kt date;
ktv number;
dtv number;
frk number;
yfrk number;
TKM VARCHAR2(10);
BEGIN
SELECT COUNT(*)
INTO adet
FROM S_URUN_DETAY
WHERE (SASI_DURUM IS NULL OR SASI_DURUM IN ('A','R'))
AND TEKLIF_NO1 = TEK1
AND TEKLIF_NO2 = TEK2;
SELECT SUM(CASE WHEN B.SASI_DURUM IS NULL OR B.SASI_DURUM IN ('A','R') THEN A.KDV_FIYAT ELSE 0 END)
INTO fat
FROM S_URUN A,S_URUN_DETAY B
WHERE A.TEKLIF_NO1 = tek1
AND A.TEKLIF_NO2 = tek2
AND A.TEKLIF_NO1 = B.TEKLIF_NO1
AND A.TEKLIF_NO2 = B.TEKLIF_NO2
AND A.SIRA_NO = B.URUN_SIRA_NO;
SELECT KULLAN_TARIH
INTO kt
FROM S_TEKLIF
WHERE TEKLIF_NO1 = tek1
AND TEKLIF_NO2 = tek2 ;
yfrk:= EXTRACT(YEAR FROM dt) - EXTRACT(YEAR FROM kt);
ktv := EXTRACT(MONTH FROM kt);
dtv := EXTRACT(MONTH FROM dt);
frk := yfrk * 12 + (dtv-ktv);
IF frk <= 0 THEN
pd := fat * 0.85;
ELSE
pd := fat*0.85 - (fat * 0.0101 * frk);
END IF;
SELECT NVL(ROUND((CASE WHEN SASI_DURUM IS NULL OR SASI_DURUM IN ('A','R') THEN pd / adet ELSE 0 END),2),0)
INTO pds
FROM S_URUN_DETAY
WHERE TEKLIF_NO1 = TEK1
AND TEKLIF_NO2 = TEK2
AND URUN_SIRA_NO = USIRA
AND SIRA_NO = SIRA;
RETURN pds;
END;
但是在我的页面中,我发现这行代码出错;
OracleDataReader dr = myCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
我在哪里做错了?
最诚挚的问候,Soner
myCommand是;
select a.hesap_no,
a.teklif_no1 || '/' || a.teklif_no2 as teklif,
a.mus_k_isim as musteri,
b.marka,
c.sasi_no,
c.sasi_durum,
d.tas_mar,
nvl(risk_sasi(a.teklif_no1, a.teklif_no2, c.urun_sira_no, c.sira_no), 0) as risk,
nvl(mv_sasi(a.teklif_no1, a.teklif_no2, c.sira_no, c.urun_sira_no, sysdate), 0) as mv
from s_teklif a,
s_urun b,
s_urun_detay c,
koc_ktmar_pr d
where a.teklif_no1 || a.teklif_no2 = b.teklif_no1 || b.teklif_no2
and a.teklif_no1 || a.teklif_no2 = c.teklif_no1 || c.teklif_no2
and b.sira_no = c.urun_sira_no
and b.distributor = d.dist_kod
and b.marka = d.marka_kod
and b.urun_kod = d.tas_kod
and a.hesap_no in (select a.hesap_no
from s_teklif a
where a.mus_k_isim in (system.collections.arraylist)
)
答案 0 :(得分:0)
我很快就遇到过这种问题。问题是:
愚蠢的oracle没有堆栈跟踪类型的错误处理机制,所以它只给出了最大的错误,这使我们无法看到其他错误。
您的函数MV_SASI没有授权供oracle用户使用。所以Oracle找不到它,并尝试像MV_SASI一样运行它。所以它给出了错误。
检查MV_SASI函数的授权和可见性设置。
答案 1 :(得分:0)
SQL末尾的这个位看起来很奇怪:WHERE A.MUS_K_ISIM IN (System.Collections.ArrayList)
。如果这真的是你的实际SQL文本,那么我认为这是你的问题。 Oracle不知道System.Collections.ArrayList
是什么。
此外,如果您要做的是将实际的arraylist绑定到SQL中,以便您可以使用IN
对其进行测试 - 这将无效。即使你成功地将它绑定到Oracle中的已知数据类型,IN
的语法也是这样的,操作数将与逗号分隔的标识符列表中的每个元素进行比较 - Oracle不会破坏列表除了你。
您需要绑定列表中的每个项目,以便您具有A.MUS_K_ISIM IN (:bind1, :bind2, :bind3)
之类的条件,或者将您的arraylist映射到Oracle中的嵌套表或varray类型,这样您就可以使用带有IN的子查询,例如{{ 1}}。