关于delphi调用oracle函数的问题.急呀!(100分)

  • 主题发起人 主题发起人 lytwyx
  • 开始时间 开始时间
L

lytwyx

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi调用代码如下:<br> &nbsp; &nbsp; &nbsp;pro_mc := ADOQuery1.FieldValues['procedure'];<br> &nbsp; &nbsp; &nbsp; ADOStoredProc1.ProcedureName := 'dbo.'+pro_mc;<br> &nbsp; &nbsp; &nbsp; ADostoredProc1.Parameters.Clear;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br><br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := pro_id;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := jq;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := bq;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := swjg_dm;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := gydm;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := zsxmdm;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; with ADostoredProc1.Parameters.AddParameter do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DataType :=ftString;<br> &nbsp; &nbsp; &nbsp; &nbsp; Direction := pdInput;<br> &nbsp; &nbsp; &nbsp; &nbsp; Value := djzclxdm;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; //ADostoredProc1.Open;<br> &nbsp; &nbsp; &nbsp; ADostoredProc1.Prepared;<br> &nbsp; &nbsp; &nbsp; ADostoredProc1.ExeExecProc;<br>函数内容如下:(函数在pl/sql中测试通过)<br><br>create or replace function pro_yyhy_zyywsrbdl(zbid in string,jq in string, bq in string,swjgdm in string,zggy in string,zsxm in string,djzclx in string) return number is<br> &nbsp;Result number;<br> &nbsp;CURSOR nsrfw (curswjgdm string,curzggydm string,curzsxm string,curdjzclx string) is &nbsp; &nbsp;--确定纳税人范围<br> &nbsp;select distinct(a.nsrsbh) from dj_nsrxx a,dj_sz b <br> &nbsp;where a.nsr_swjg_dm like trim(curswjgdm) and a.zg_swgy_dm like trim(curzggydm) and<br> &nbsp;a.nsrsbh=b.nsrsbh and b.zsxm_dm like trim(curzsxm) and a.nsr_swjg_dm=b.nsr_swjg_dm and <br> &nbsp;a.djzclx_dm like trim(curdjzclx) and (a.nsrmc like '%医药%' or a.hy_dm='2700') and a.nsrzt_dm in<br> &nbsp;('10','21','22','23','71');<br> &nbsp;/*<br> &nbsp;目前纳税人的范围还没有确定<br> &nbsp;*/<br> &nbsp;--CURSOR nsrfw is &nbsp; &nbsp;--确定纳税人范围<br> &nbsp; --select nsrsbh from dj_nsrxx where nsrsbh='620103756556236';<br> &nbsp;nsrsbh &nbsp; &nbsp;VARCHAR2(20); &nbsp;--纳税人识别号<br> &nbsp;jqnd &nbsp; &nbsp; &nbsp;char(4); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --基期年<br> &nbsp;jqyq &nbsp; &nbsp; &nbsp;char(10); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--基期起<br> &nbsp;jqyz &nbsp; &nbsp; &nbsp;char(8); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --基期止<br> &nbsp;jqsr &nbsp; &nbsp; &nbsp;number; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --基期收入<br> &nbsp;jqljsr &nbsp; &nbsp;number; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --基期累计收入<br> &nbsp;bqnd &nbsp; &nbsp; &nbsp;char(4); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --本期年<br> &nbsp;bqyq &nbsp; &nbsp; &nbsp;char(8); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--本期起<br> &nbsp;bqyz &nbsp; &nbsp; &nbsp;char(8); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --本期止<br> &nbsp;bqsr &nbsp; &nbsp; &nbsp;number; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --本期收入<br> &nbsp;bqljsr &nbsp; &nbsp;number; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --本期累计收入<br> &nbsp;pzxh &nbsp; &nbsp; &nbsp;CHAR(16); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--sb_zzs_2003_fb.pzxh<br> &nbsp;bz &nbsp; &nbsp; &nbsp; &nbsp;number(4,2); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--基期本期比值<br> &nbsp;pgjgxh &nbsp; &nbsp;char(8); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --评估结果id<br> &nbsp;pgsj &nbsp; &nbsp; &nbsp;date; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--评估时间 &nbsp;<br> &nbsp;tablejq &nbsp; char(9);<br> &nbsp;tablebq &nbsp; char(9);<br> &nbsp;cszggy &nbsp; &nbsp;char(11);<br> &nbsp;cszsxm &nbsp; &nbsp;char(2);<br> &nbsp;csdjzclx &nbsp;char(2);<br> &nbsp;inswjgdm &nbsp;char(11);<br> &nbsp;CURSOR jqsrpzxh(curjqyq string,curjqyz string,curnsrsbh string) is &nbsp; --确定基期收入pzxh<br> &nbsp; select pzxh from sb_zzs_2003_fb where fblx='FB6' and to_date(to_char(sssq_q,'yyyy-mm'),'yyyy-mm') between to_date(curjqyq,'yyyy-mm') and to_date(curjqyz,'yyyy-mm') and nsrsbh=curnsrsbh; <br> &nbsp;CURSOR bqsrpzxh (curbqyq string,curbqyz string,curnsrsbh string) is &nbsp;--确定基期收入pzxh<br> &nbsp; select pzxh from sb_zzs_2003_fb where fblx='FB6' and to_date(to_char(sssq_q,'yyyy-mm'),'yyyy-mm') between to_date(curbqyq,'yyyy-mm') and to_date(curbqyz,'yyyy-mm') and nsrsbh=curnsrsbh; <br> &nbsp;CURSOR jqsrls(curpzxh string) is &nbsp; &nbsp; --确定主营业务收入<br> &nbsp; select bys from sb_zzs_2003_fb6 where pzxh= curpzxh and fbxm_dm='6101'; &nbsp;<br>begin<br> &nbsp;--首先确定游标是否有记录<br> &nbsp;if zggy &nbsp;='全部' then<br> &nbsp; &nbsp;cszggy &nbsp; := '%';<br> &nbsp;end if;<br> &nbsp;if zsxm &nbsp;='全部' then<br> &nbsp; &nbsp;cszsxm &nbsp; := '%';<br> &nbsp;end if;<br> &nbsp;if djzclx='全部' then<br> &nbsp; &nbsp;csdjzclx := '%';<br> &nbsp;end if;<br> &nbsp;OPEN nsrfw(swjgdm,cszggy,cszsxm,csdjzclx);<br> &nbsp;FETCH nsrfw into nsrsbh;<br> &nbsp;IF (nsrfw%NOTFOUND) then<br> &nbsp; &nbsp;Result :=100; &nbsp;--没有发现符合范围的纳税人<br> &nbsp;ELSE<br> &nbsp; &nbsp;jqnd := trim(substr(jq,1,4));<br> &nbsp; &nbsp;jqyq := jqnd ||'-'|| trim(substr(jq,5,2));<br> &nbsp; &nbsp;jqyz := jqnd ||'-'|| trim(substr(jq,7,2));<br> &nbsp; &nbsp;bqnd := substr(bq,1,4);<br> &nbsp; &nbsp;bqyq := jqnd ||'-'|| trim(substr(bq,5,2));<br> &nbsp; &nbsp;bqyz := jqnd ||'-'|| trim(substr(bq,7,2));<br> &nbsp; &nbsp;--处理税务机关代码<br> &nbsp; if length(swjgdm)&lt;11 then<br> &nbsp; &nbsp; inswjgdm:=substr(swjgdm,1,length(swjgdm)-1);<br> &nbsp; &nbsp; while not(length(inswjgdm)&lt;11) loop<br> &nbsp; &nbsp; &nbsp; inswjgdm:= inswjgdm || '0';<br> &nbsp; &nbsp; end loop;<br> &nbsp; else<br> &nbsp; &nbsp; inswjgdm := swjgdm;<br> &nbsp; end if;<br> &nbsp; <br> &nbsp; &nbsp;select FBXH.NEXTVAL into pgjgxh from dual;<br> &nbsp; &nbsp;select sysdate into pgsj from dual; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp;insert into nspg_pgjg values(pgjgxh,zbid,jq,bq,inswjgdm,zggy,zsxm,djzclx,pgsj);<br> &nbsp; &nbsp;WHILE not(nsrfw%NOTFOUND) LOOP<br> &nbsp; &nbsp; &nbsp;jqsr := 0;<br> &nbsp; &nbsp; &nbsp;jqljsr := 0;<br> &nbsp; &nbsp; &nbsp;--提取基期的主营业务收入<br> &nbsp; &nbsp; &nbsp;OPEN jqsrpzxh(jqyq,jqyz,nsrsbh);<br> &nbsp; &nbsp; &nbsp;FETCH jqsrpzxh into pzxh;<br> &nbsp; &nbsp; &nbsp;if (jqsrpzxh%NOTFOUND) then<br> &nbsp; &nbsp; &nbsp; &nbsp;Result := 100;<br> &nbsp; &nbsp; &nbsp;ELSE<br> &nbsp; &nbsp; &nbsp; &nbsp;WHILE NOT(jqsrpzxh%NOTFOUND) LOOP<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OPEN jqsrls(pzxh);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FETCH jqsrls into jqsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (jqsrls%NOTFOUND) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := 100;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ELSE<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WHILE NOT(jqsrls%NOTFOUND) LOOP<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jqljsr := jqljsr + jqsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FETCH jqsrls into jqsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END LOOP; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END IF;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CLOSE jqsrls;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FETCH jqsrpzxh into pzxh;<br> &nbsp; &nbsp; &nbsp; &nbsp;END LOOP; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp;END IF;<br> &nbsp; &nbsp; &nbsp;CLOSE jqsrpzxh;<br> &nbsp; &nbsp; &nbsp;--提取本期的主营业务收入<br> &nbsp; &nbsp; &nbsp;bqsr := 0;<br> &nbsp; &nbsp; &nbsp;bqljsr := 0; &nbsp;<br> &nbsp; &nbsp; &nbsp;OPEN bqsrpzxh(bqyq,bqyz,nsrsbh);<br> &nbsp; &nbsp; &nbsp;FETCH bqsrpzxh into pzxh;<br> &nbsp; &nbsp; &nbsp;if (bqsrpzxh%NOTFOUND) then<br> &nbsp; &nbsp; &nbsp; &nbsp;Result := 100;<br> &nbsp; &nbsp; &nbsp;ELSE<br> &nbsp; &nbsp; &nbsp; &nbsp;WHILE NOT(bqsrpzxh%NOTFOUND) LOOP<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OPEN jqsrls(pzxh);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FETCH jqsrls into bqsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (jqsrls%NOTFOUND) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := 100;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ELSE<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WHILE NOT(jqsrls%NOTFOUND) LOOP<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bqljsr := bqljsr + bqsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FETCH jqsrls into bqsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END LOOP;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--计算基期和本期比值<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if jqljsr=0 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bz := 0;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bz := (bqljsr-jqljsr)/jqljsr;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end if;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--插入nspg_pgjg、nspg_pgjg_mx表中<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--SET TRANSACTION READ WRITE;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert into nspg_pgjg_mx values(pgjgxh,nsrsbh,bqljsr-jqljsr,bqljsr,bz);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := 10;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END IF;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CLOSE jqsrls;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FETCH bqsrpzxh into pzxh;<br> &nbsp; &nbsp; &nbsp; &nbsp;END LOOP;<br> &nbsp; &nbsp; &nbsp;END IF; <br> &nbsp; &nbsp; &nbsp;CLOSE bqsrpzxh; &nbsp; <br> &nbsp; &nbsp; &nbsp;FETCH nsrfw into nsrsbh;<br> &nbsp; &nbsp;END LOOP;<br> &nbsp; &nbsp;commit;<br> &nbsp; &nbsp;CLOSE nsrfw; &nbsp; &nbsp;<br> &nbsp;END IF; <br> &nbsp;return(Result);<br>end pro_yyhy_zyywsrbdl;<br>/<br>错误提示:<br><br>Project project1.exe raised exception class EOLeEcception with message 'ORA-06550'<br>line 1 column 7:<br>PLS-00221 :'PRO_YYHY_ZYYWSRBDL' is not a procedure or is undefined<br>ORA_06550: line1 column7:<br>PL/SQL:statement ignored process stopped use step or run to continue
 
没人顶,自己先
 
不用proc控件<br>执行select 函数名() from dual
 
我是要执行我自己写的一个函数:<br>create or replace function pro_yyhy_zyywsrbdl(zbid in string,jq in string, bq in string,swjgdm in string,zggy in string,zsxm in string,djzclx in string)
 
后退
顶部