SQLPlus Error handle
SQLPlus directive "WHENEVER SQLERROR EXIT 1" will return a specified code when any SQL error throwed when run a sql file.
Then we can catch the return code from the main bat file (where we call the sqlplus) to test it and then jump to a correspondence code.
Below is a example, gpdemo.sql is a normal sql file, it will be execute by sqlplus called from main.bat.
The main.bat will test the return code to know whether any sql error occurred when execute the gpdemo.sql.
gpdemo.sql
WHENEVER SQLERROR EXIT 1; DECLARE
V_USER_EXISTED INT;
BEGIN
SELECT COUNT(1) INTO V_USER_EXISTED FROM DBA_USERS WHERE USERNAME='GPDEMO'; IF V_USER_EXISTED >= 1 THEN
EXECUTE IMMEDIATE 'DROP USER GPDEMO CASCADE';
END IF; EXECUTE IMMEDIATE 'CREATE USER GPDEMO IDENTIFIED BY SUNGARD01'; EXECUTE IMMEDIATE 'GRANT CREATE TABLE TO GPDEMO'; EXECUTE IMMEDIATE 'GRANT CREATE VIEW TO GPDEMO'; EXECUTE IMMEDIATE 'GRANT CREATE PROCEDURE TO GPDEMO'; EXECUTE IMMEDIATE 'GRANT CREATE SEQUENCE TO GPDEMO'; EXECUTE IMMEDIATE 'GRANT CREATE SYNONYM TO GPDEMO'; EXECUTE IMMEDIATE 'GRANT CREATE SESSION TO GPDEMO'; EXECUTE IMMEDIATE 'GRANT GETPAID_ROLE TO GPDEMO'; EXECUTE IMMEDIATE 'ALTER USER GPDEMO DEFAULT TABLESPACE GP_DATA'; EXECUTE IMMEDIATE 'ALTER USER GPDEMO TEMPORARY TABLESPACE TEMP'; EXECUTE IMMEDIATE 'ALTER USER GPDEMO QUOTA UNLIMITED ON GP_DATA'; EXECUTE IMMEDIATE 'ALTER USER GPDEMO QUOTA UNLIMITED ON GP_INDX';
END;
/ EXIT 0
main.bat
:: Clear the ERRORLEVEL environment if it had defined.
set ERRORLEVEL =
:: Drop and recreate GPDEMO
sqlplus system/manager@GPODTE @gpdemo.sql >> DROPUSER.log
:: RELOAD dump file to GPDEMO
if ERRORLEVEL 1 (
ECHO "Failed to Drop user, check the DROPUSER.log for detail error message"
) else (
ECHO "Drop User Successfully, will continute to do import"
imp system/manager@GPODTE fromuser=gpcomp1 touser=GPDEMO file=gpdemo.dmp log=gpdemo.log statistics=none
)
SQLPlus Error handle的更多相关文章
- sqlplus: error while loading shared libraries: /u01/app/lib/libclntsh.so.11.1
成功安装了Oracle 11g后,使用sqlplus登录数据库时遇到下面错误: [oracle@DB-Server ~]$ sqlplus / as sysdba sqlplus: error w ...
- sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file 1. 权限问题 ...
- ORACLE11.2.0 SQLPLUS 报 error while loading shared libraries
相应的环境平台: OS: Linux TEST11G 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux ...
- Android Volley gives me 400 error
本文来自:http://stackoverflow.com/questions/21739276/android-volley-gives-me-400-error 本人是根据文中的其中一方法: I ...
- Cloning EBS from Linux 5 to Linux 6 Fails: "Error While Loading Shared Libraries: libclntsh.so.10.1
SYMPTOMS During clone Oracle Applications R12 from Linux 5 to Linux 6 the following error occurs ...
- sqlplus 一次奇葩问题 HTTP proxy setting has incorrect value
y@y:~$ sqlplus Error 46 initializing SQL*PlusHTTP proxy setting has incorrect valueSP2-1502: The HTT ...
- 20140603 对error.c 用于分析源代码
20140603 对error.c 用于分析源代码 继续看error.c该功能 买家现在将自己的代码和数据汇编例如,下面的: 1.#include <stdio.h> 2 #inc ...
- 【Oracle】-【sqlplus / as sysdba登录报错问题】-新用户使用sqlplus / as sysdba登录报错
刚才打开一个别人的测试库,用root登陆了的,sqlplus / as sysdba竟然报错,奇怪,于是在自己的VM中模拟该过程. 新建了一个test用户: [test@liu bin]# ./sql ...
- 不一样的go语言-error
前言 go语言的error处理方式,在目前流行的编程语言中属于刺头.似乎天生就是用来有别于他人标记.TIOBE排行榜全十除了C语言,无一例外是try catch的阵营.而排在go之前的语言除了C与 ...
随机推荐
- winform学习-----理解小概念-20160518
一.设置滚动,滚动列遮住内容的解决办法 1.datagridview三个属性:autosizecolumsmode none autosizeRowsmode none dock fill 2. ...
- 带你学C,带你飞——入门
- MySQL 记录不存在时插入 记录存在则更新的实现方法
INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; INSERT 中 ON DUPLICATE KEY UP ...
- sqlmap遇到url重写的示例
url_rewrite 这个问题 国内外的坛子里都有人问. D:\cygwin\pentest\database\sqlmap\doc \faq.pdf 下面是官方给的解答. 1.15 How to ...
- 对于PKI(公钥基础结构)及证书服务的通俗理解
对于PKI及证书服务的这些概念,相信初学者会有许多迷惑的地方,那是因为其中的某些关键概念没有理解清楚,我力争以通俗易懂的方式给初学者一些启示,也给以后自己忘了的时候一个参考:) ! 参考资料:http ...
- 使用Eclipse开发Java Web过程中Debug调试的使用方法
里介绍的是在Eclipse中的Debug调试. 首先右击项目选择Debug As -- Debug on Server 或者点击Server面板的小昆虫图标,启动Debug模式. 运行web项目,进行 ...
- VS 本机调试
VS~通过IIS网站启用"域名"调试 在我们开发网站时,对某些信息进行序列化时,通常使用session,cookies,nosql等技术,而为了安全,我们在服务器上很多情况都做了防 ...
- LAMP环境搭建教程(原创)
学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一. ...
- Flink - FlinkKafkaConsumer08
先看 AbstractFetcher 这个可以理解就是,consumer中具体去kafka读数据的线程,一个fetcher可以同时读多个partitions的数据来看看 /** * Base cl ...
- 利用sqlserver日志恢复数据
如果你已经急的焦头烂额,看到这篇文章的时候,请你换个坐姿,深呼吸几次,静下心来将这篇文章读完,也许你的问题迎刃而解. 我遇 到的情况是这样的,网站被植入木马,盗取了我的web.config文件,web ...