sqlplus

Managing error handling while running sqlplus from shell scripts

怎甘沉沦 提交于 2019-11-28 23:39:37
问题 #!/bin/sh echo "Please enter evaluate database username" read eval_user echo "Please enter evaluate database password" read eval_pass echo "Please enter the database name" read db_name LOGFILE=shell_log.txt $ORACLE_HOME/bin/sqlplus -s /nolog <<-EOF>> ${LOGFILE} connect $eval_user/$eval_pass@$db_name WHENEVER OSERROR EXIT 9; WHENEVER SQLERROR EXIT SQL.SQLCODE; DBMS_OUTPUT.put_line('Connected to db'); EOF if [ $? != 0 ] then echo "The upgrade script failed. Please refer to the log results.txt

How do you execute SQL from within a bash script?

♀尐吖头ヾ 提交于 2019-11-28 23:27:27
I have some SQL scripts that I'm trying to automate. In the past I have used SQL*Plus, and called the sqlplus binary manually, from a bash script. However, I'm trying to figure out if there's a way to connect to the DB, and call the script from inside of the bash script... so that I can insert date and make the queries run relative to a certain number of days in the past. I'm slightly confused. You should be able to call sqlplus from within the bash script. This may be what you were doing with your first statement Try Executing the following within your bash script: #!/bin/bash echo Start

How do I exit a script in SQLPlus when an error occurs and return to the SQLPlus prompt, without disconnecting or exiting SQLPlus?

痴心易碎 提交于 2019-11-28 23:16:42
问题 I have some scripts that get run often, always from within a connected SQLPlus session. I need a way to exit the script when an error occurs, without disconnecting or exiting SQLPlus itself. 100% of the time, when an error occurs, the connected DBA will need to issue one or more commands into the session. 100% of the time, when an error occurs, there are other SQLPlus statements (and thus must be outside of a BEGIN..END; ) later on in the script that must not be executed or serious problems

How do I format my oracle queries so the columns don't wrap?

大兔子大兔子 提交于 2019-11-28 22:42:57
I've tried this, but it doesn't work: col * format a20000 Do I really have to list every column specifically? That is a huge pain in the arse. someguy Never mind, figured it out: set wrap off set linesize 3000 -- (or to a sufficiently large value to hold your results page) Which I found by: show all And looking for some option that seemed relevant. I use a generic query I call "dump" (why? I don't know) that looks like this: SET NEWPAGE NONE SET PAGESIZE 0 SET SPACE 0 SET LINESIZE 16000 SET ECHO OFF SET FEEDBACK OFF SET VERIFY OFF SET HEADING OFF SET TERMOUT OFF SET TRIMOUT ON SET TRIMSPOOL ON

sqlplus remote connection giving ORA-21561

半城伤御伤魂 提交于 2019-11-28 21:13:28
I have installed sqlplus based on instruction given here sqlplus 'username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1521))(CONNECT_DATA=(SID=ORCL)))' This is giving me error SQL*Plus: Release 11.2.0.4.0 Production on Fri Jul 10 16:10:38 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-21561: OID generation failed Enter user-name: What is the solution for this problem? PS: I have already added hostname and hosts have already have value. Prasanth Pennepalli Append the name of your server to the hosts file. If your /etc/hosts file looks like

CLEAR SCREEN - Oracle SQL Developer shortcut?

喜夏-厌秋 提交于 2019-11-28 21:12:50
With the aim of reducing mouse activity i was wondering if there was such a command shortcut (eg CLS or Ctrl+L) to provide the SQL*Plus (?) "CLEAR SCREEN" command functionality found by clicking the rubber-on-end-of-pencil icon in Oracle SQL Developer to clear the lower "Results" sub-tab (...incorrect terminology i'm sure). Rahul To clear the SQL window you can use: clear screen; which can also be shortened to cl scr; If you're using sqlplus in a shell, like bash you can run the shell's clear command from sqlplus: SQL> host clear you can abbreviate of course: SQL> ho clear SQL>Clear Screen (It

How to install SQL * PLUS client in linux

大城市里の小女人 提交于 2019-11-28 19:55:15
问题 I am working on AWS services. I have an ec2 ( centos ) instance. I need to configure SQL*Plus client on this centos machine. The server with whom I want to connect is at some remote area. The server version is oracle-se(11.2.0.2) Kindly help me getting the client installed on the centos machine. Thanks in advance. 回答1: Go to Oracle Linux x86-64 instant clients download page Download the matching client oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2

How do I pass arguments to a PL/SQL script on command line with SQLPLUS?

我们两清 提交于 2019-11-28 19:12:25
How do I pass arguments to a PL/SQL script on command line with SQLPLUS? I can call my PL/SQL script like so, but the script requires arguments in order for it to succeed. How can I run sqlplus.exe so that I can pass arguments to the script? @ECHO off // where HOST030 is a tnsnames alias to a machine, port, and instance sqlplus.exe MYUSER/mypassword@HOST030 < refreshDataOnOracle.sql pause I tried to search for the answer but couldn't find an "argument example" anywhere for SQLPLUS. I suspect it would be a similar method of using the SQL*Plus "START" command? Firstly, you will need to invoke

How to output oracle sql result into a file in windows?

邮差的信 提交于 2019-11-28 18:15:53
I tried select * from users save D:\test.sql create; But SQL plus gives me "no proper ended" How to specify path in oracle sql in windows? Use the spool: spool myoutputfile.txt select * from users; spool off; Note that this will create myoutputfile.txt in the directory from which you ran SQL*Plus. If you need to run this from a SQL file (e.g., "tmp.sql") when SQLPlus starts up and output to a file named "output.txt": tmp.sql: select * from users; Command: sqlplus -s username/password@sid @tmp.sql > output.txt Mind you, I don't have an Oracle instance in front of me right now, so you might need

Does SQLDeveloper support executing scripts?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 17:33:30
I was trying to follow some instructions today, and it starts with the comment REM In SQLPlus I manually copy in each line and execute it. That's nice, I don't have SQLPlus, I have SQLDeveloper. The lines that were pasted in were of the type: @\\server\dir\dir\dir\commandfile1.txt; COMMIT; ...etc. It didn't like it when I tried that in a SQL window. I opened up and pasted in the commands by hand, and it wasn't happy with that either. (Did I mention that I'm not so good with this application nor Oracle, but that everyone else was out today?) The files there started with code like: rem set echo