本教程操作环境:Windows10系统、Oracle 11g版、Dell G3电脑。
怎样执行oracle存储过程
示例:有如下创建索引的存储过程
--procedure create_indexcreate or replace procedure create_index(indexName in varchar2, tablename in varchar2, columnName in varchar2)itmp_name VARCHAR2(50);TMP_SQL VARCHAR2(1024);cnt NUMBER;beginselect table_name into tmp_name from user_tables where upper(table_name)=upper(tableName);if length(tmp_name)>0 thenSELECT COUNT(*) INTO cnt FROM USER_INDEXES T WHERE T.TABLE_NAME=''|| tableName ||'' AND T.INDEX_NAME=''|| indexName;IF cnt = 0 THENexecute immediate 'create index ' || indexName ||' on ' || tableName ||'('|| columnName ||') TABLESPACE TBS_TXNIDX';END IF;end if;EXCEPTIONWHEN NO_DATA_FOUND THENBEGINNULL;END;end;
1)在命令窗口下: exec 存储过程(参数...);
exec create_index('IDX_ORG_SET_PROCESS_1','CPS_ORG_SETTLEMENT_PROCESS','ORG_IDENTITY_ID ASC');
2)在sql窗口下:
begincreate_index('IDX_STATEMENT_DETAIL_LINK','CPS_BANK_STATEMENT_DETAIL','LINK_TXN_ID ASC');end;
推荐教程:《Oracle视频教程》
免责声明:本站内容仅用于学习参考,信息和图片素材来源于互联网,如内容侵权与违规,请联系我们进行删除,我们将在三个工作日内处理。联系邮箱:chuangshanghai#qq.com(把#换成@)