ORACLE存储过程创建失败,如何查看其原因
Posted 癫狂编程
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORACLE存储过程创建失败,如何查看其原因相关的知识,希望对你有一定的参考价值。
工作中用SQL Server比较多,Oracle可以说是小白,最近想用存储过程来完成单据复制的功能,结果遇到各种问题,其实都是非常简单的问题,但是对我来说还是花了很多时间来解决,浪费这些时间非常不值得,也由此让我越发喜爱微软的产品,不管是Visual Studio、SQL Server Management Studio还是Office,易用性都是非常的好。
我要创建的存储过程并不复杂,就是插入表的字段真TMD多,代码如下:
create or replace procedure procPushMeasure(p_pk_measure varchar2) as v_pk_measure char(20); begin --新单据的主键为原主键中第5-8位替换为\'PUSH\' v_pk_measure := substr(p_pk_measure, 1, 4)||\'PUSH\'||substr(p_pk_measure, 9); dbms_output.put_line(p_pk_measure||\' => \'||v_pk_measure); insert into jgpm_cm_measure(pk_measure, vbillno, vbillstatus, biscollect, bissplit, bisupload, dapprovedate, dbilldate, dmakedate, dmeapprodate, dr, dreportdate, napplybasemny, napplyorigmny, napplyrate, nbaserate, ncanpaybasemny, ncanpayorigmny, ncanpayrate, ncontbasemny, ncontorigmny, ncurrpaybasemny, ncurrpayorigmny, ncurrprodbasemny, ncurrprodorigmny, nexecbasemny, nexecorigmny, nmeaapplybasemny, nmeaapplyorigmny, nmeaapprbasemny, nmeaapprorigmny, nmeasurbasemny, nmeasurorigmny, npaybasemny, npayorigmny, npayrate, nprevpaybasemny, nprevpayorigmny, nprevprodbasemny, nprevprodorigmny, nsumapplybasemny, nsumapplyorigmny, nsummeabasemny, nsummeaorigmny, pk_basetype, pk_billtype, pk_cont, pk_corp, pk_file, pk_origintype, pk_project, pk_source, sourcets, sourcetype, ts, vapproveid, vapprovenote, vauditor, vconmanager, vdealerid, vdef1, vdef10, vdef2, vdef3, vdef5, vdef6, vdef7, vdef8, vdef9, vdeptid, vmemo, voperatorid, vprocess, vrealmeasno, vreserve1, vreserve10, vreserve2, vreserve3, vreserve4, vreserve5, vreserve6, vreserve7, vreserve8, vreserve9, vsupermanager, vyearprojpoint, dreceiptdate, vmanagerpinion, vapprvstatus, vrealprocess, nmeaapprorigmnypart1, nmeaapprbasemnypart1, nmeaapprorigmnypart2, nmeaapprbasemnypart2, nmeaapprorigmnypart3, nmeaapprbasemnypart3, itermno, vyearmonth, dtermbegindate, dtermenddate, nmeaapplyedorigmny, nmeaapplyedbasemny, pk_valstat, nmeaapplyedbasemny, nmeaapplyedorigmny) SELECT v_pk_measure, \'T85L\'||substr(vbillno,5), 8, biscollect, bissplit, bisupload, dapprovedate, dbilldate, dmakedate, dmeapprodate, dr, dreportdate, napplybasemny, napplyorigmny, napplyrate, nbaserate, ncanpaybasemny, ncanpayorigmny, ncanpayrate, ncontbasemny, ncontorigmny, ncurrpaybasemny, ncurrpayorigmny, ncurrprodbasemny, ncurrprodorigmny, nexecbasemny, nexecorigmny, nmeaapplybasemny, nmeaapplyorigmny, nmeaapprbasemny, nmeaapprorigmny, nmeasurbasemny, nmeasurorigmny, npaybasemny, npayorigmny, npayrate, nprevpaybasemny, nprevpayorigmny, nprevprodbasemny, nprevprodorigmny, nsumapplybasemny, nsumapplyorigmny, nsummeabasemny, nsummeaorigmny, pk_basetype, pk_billtype, pk_cont, pk_corp, pk_file, pk_origintype, pk_project, pk_source, sourcets, sourcetype, ts, vapproveid, vapprovenote, vauditor, vconmanager, vdealerid, vdef1, vdef10, vdef2, vdef3, vdef5, vdef6, vdef7, vdef8, vdef9, vdeptid, vmemo, voperatorid, vprocess, vrealmeasno, vreserve1, vreserve10, vreserve2, vreserve3, vreserve4, vreserve5, vreserve6, vreserve7, vreserve8, vreserve9, vsupermanager, vyearprojpoint, dreceiptdate, vmanagerpinion, vapprvstatus, vrealprocess, nmeaapprorigmnypart1, nmeaapprbasemnypart1, nmeaapprorigmnypart2, nmeaapprbasemnypart2, nmeaapprorigmnypart3, nmeaapprbasemnypart3, itermno, vyearmonth, dtermbegindate, dtermenddate, nmeaapplyedorigmny, nmeaapplyedbasemny, pk_valstat, nmeaapplyedbasemny, nmeaapplyedorigmny FROM jgpm_cm_measure WHERE pk_measure=p_pk_measure; end;
在PL/SQL Developer中执行后创建存储过程的脚本后,却无法通过下面的脚本来调用该存储过程,报告错误:对象无效
在左边的对象列表中展开Procedures,可以见到该存储过程前面有一个红叉,说明存储过程创建得有问题,将字段数目减少到只有两三个必要字段的时候,存储过程创建成功了,但因为字段太多了,一个一个字段的加进去,再测试创建是不是成功的办法实在有点笨。
折腾很久之后终于找到了办法,在该存储过程上点右键,选择查看
后面的事情就好办了
以上是关于ORACLE存储过程创建失败,如何查看其原因的主要内容,如果未能解决你的问题,请参考以下文章