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与 ...
随机推荐
- org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /user/hive/warehouse/page_view. Name node is in safe mode
FAILED: Error in metadata: MetaException(message:Got exception: org.apache.hadoop.ipc.RemoteExceptio ...
- 决策树ID3算法示例
决策树代码如下: #include "MyID3.h" using namespace std; void ReadData() //读入数据 { ifstream fin(&qu ...
- unserialize函数中的参数是否是污染数据
1.原理 在程序编写的时候,往往需要序列化一些运行时数据,所谓序列化就是按照一定的格式将运行时数据写入本地文件.这样做可以对数据进行本地保存,用的时候直接读文件就可以把运行时产生的数据读出.php中就 ...
- 描述了say_hello函数的具体内容,调用zend_printf系统函数在php中打印字符串
下载一个php的源代码包,这里使用的是php 4.0.5版,解压后会看到php的根目录下会有README.EXT_SKEL这样一个文件,打开详细阅读了一下,发现了一个非常好用的工具,这个工具可以帮你构 ...
- [转]IE11下Forms身份认证无法保存Cookie的问题
本文转自:http://www.cnblogs.com/jaxu/p/3698377.html ASP.NET中使用Forms身份认证常见的做法如下: 1. 网站根目录下的Web.config添加au ...
- OpenCV学习笔记——视频的边缘检测
使用Canny算子进行边缘检测,并分开输出到三个窗口中,再给每一个窗口添加文字 代码: #include"cv.h" #include"highgui.h" / ...
- Magento架构分析,Magento MVC 设计分析
Magento架构分析,Magento MVC 设计分析 分类:Magento 标签:Magento MVC.Magento架构 669人浏览 Magento 采用类似 JAVA的架构,其扩展与稳定性 ...
- DateTime Related Functions
string a = "to_date('" + dtpStart.Value.ToString("yyyy/MM/dd") + "', 'yyyy/ ...
- selenium测试套件
1.测试套件测试套件,简单理解就是讲多个用例,装在一个容器里来同时执行完成. 2.测试套件分析 #coding=utf-8 import unittestimport BaiDuSearch,BaiD ...
- ubuntu timezone
change timezone sudo dpkg-reconfigure tzdata synchronize time sudo ntpdate time.windows.com