I have written a shell script where I'm trying to update oracle table, while updating table I'm experiencing below error on other hand when I'm executing with given hard coded values it is working fine.
Code
DAT_SUPPL_ID='21'
PA_OLT_CD='32'
DT_PY_FD_TY='43'
DT_FL_MTH='M201565'
sqlplus -silent XXX/YYY#UDF <<!
UPDATE HX_DT_PUC_DOL SET PROC_STA_TS=SYSTIMESTAMP,PROC_ID=1 WHERE DT_SPPL_INT_ID='${DAT_SUPPL_ID}' AND PH_CD='${PA_OLT_CD}' AND DAT_PY_FD_TY='${DT_PY_FD_TY}' AND DT_FLE_MONTH='${DT_FL_MTH}'
exit;
!
Error:
UPDATE HX_DT_PUC_DOL SET PROC_STA_TS=SYSTIMESTAMP,PROC_ID=1 WHERE DT_SPPL_INT_ID='21' AND PH_CD='1981808' AND DAT_PY_FD_TY='1' AND DT_FLE_MONTH='M200911'
*
ERROR at line 1:
ORA-00942: table or view does not exist
Working Code
sqlplus -silent XXX/YYY#UDF <<!
UPDATE HX_DT_PUC_DOL SET PROC_STA_TS=SYSTIMESTAMP,PROC_ID=1 WHERE DT_SPPL_INT_ID='21' AND PH_CD='1981808' AND DAT_PY_FD_TY='1' AND DT_FLE_MONTH='M200911'
!
Add a semicolon after the end of sql.
-bash-4.2$ sqlplus hr/hr
SQL*Plus: Release 11.2.0.2.0 Production on Tue Apr 10 15:40:04 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> create table test_table (col1 date, col2 number, col3 number, col4 varchar2(30));
Table created.
SQL> insert into test_table (col1,col2,col3,col4) values (sysdate, 1,1234,'#T!ger');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test_table;
COL1 COL2 COL3 COL4
------------------ ---------- ---------- ------------------------------
10-APR-18 1 1234 #T!ger
SQL> exit
#!/bin/sh
test_num1='1234'
test_char2='#T!ger'
sqlplus hr/hr <<!
UPDATE TEST_TABLE SET col1=SYSDATE , col2=4 WHERE col3='${test_num1}' AND col4='${test_char2}' ;
commit;
exit;
!
bash-4.2$ ./test_sql.sh
SQL*Plus: Release 11.2.0.2.0 Production on Tue Apr 10 16:11:08 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> SQL>
1 row updated.
SQL>
Commit complete.
SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
sql without ;
bash-4.2$ ./test_sql.sh
SQL*Plus: Release 11.2.0.2.0 Production on Tue Apr 10 16:16:30 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> SQL> 2 exit
*
ERROR at line 2:
ORA-00933: SQL command not properly ended
SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
bash-4.2$ more test_sql.sh
#!/bin/sh
test_num1='1234'
test_char2='#T!ger'
sqlplus hr/hr <<!
UPDATE TEST_TABLE SET col1=SYSDATE , col2=4 WHERE col3='${test_num1}' AND col4='${test_char2}'
exit;
!
Related
I am simply trying to execute the a query using sqlplus, but nothing gets written in the Log file.
sqlplus -s "USERNAME/PASSWORD#hostname:port/SID" <<< $sql > $fileName.txt
The variables are
sql="select count(*) from dual"
fileName=SONU_CODE_CHANGES
But when I run it nothing gets written in fileName.txt, when I execute on command line, I get the records and when I execute it without -S flag, I get the following written in LOG file
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Oct 27 01:56:17 2022
Version 19.16.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Last Successful login time: Thu Oct 27 2022 01:56:00 -04:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.16.0.0.0
SQL> 2 Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.16.0.0.0
I am stuck on this problem since a long time, any help is highly appreciated.
Unable to connect using SQLplus after installation of Oracle.
[oracle#78787~]$ sqlplus SYS/Oracle_1#cdb1 AS SYSDBA
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Dec 29 11:38:40 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Adding few more details
I get connected after getting the error and giving the username and password again, like below. The console prompts for entering username and password again.
[oracle#78787~]$ sqlplus SYS/Oracle_1#cdb1 AS SYSDBA
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Dec 29 12:11:31 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
**ORA-12154: TNS:could not resolve the connect identifier specified**
Enter user-name: SYS as SYSDBA
Enter password:
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> exit;
I do not find tnsnames.ora file and sqlnet.ora in the below path, but those are inside samples. And the ones inside samples looks like sample files, with most lines commented.
ls -lrt $ORACLE_HOME/network/admin
total 4
-rw-r--r--. 1 oracle oinstall 1536 Feb 13 2018 shrept.lst
drwxr-xr-x. 2 oracle oinstall 64 Dec 29 07:01 samples
I have a linux server OEL 5.8 in which 8 oracle DB instances are running. 4 Db instances are running on Oracle 10.2.0.4 and other 4 on 11.2.0.3. Initially, all the DB instances were running on 10.2.0.4. I upgraded 4 of them to 11.2.0.3. Now the existing linux server is going to be migrated on new location. Server was cloned to the new server location and I got the exact replica of my old server at new location. I was able to start the Oracle 10g DB instances perfectly fine just changing the hostname in tnsnames.ora and listener.ora. However I am unable to start ORacle 11g instances. sqlplus is unable to find the Db instance. $ORACLE_SID, $ORACLE_HOME and $PATH are set to oracle 11g location in environment variables. Pfile exists in $ORACLE_HOME/dbs. But when I try to connect like 'sqlplus / as sysdba' I am unable to find any idle instnace to start.
flow81 > echo $ORACLE_HOME
/dboracle/orabase/product/11.2.0.3
flow81 > echo $PATH
/dboracle/orabase/product/11.2.0.3/bin
flow81 > echo $ORACLE_SID
flow81
flow81 > sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 19 05:58:01 2017
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected.
SQL>
For DB instances in 10g,
fltr81 > sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Sep 19 06:00:10 2017
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> STARTUP
ORACLE instance started.
Total System Global Area 159383552 bytes
Fixed Size 2082464 bytes
Variable Size 113248608 bytes
Database Buffers 37748736 bytes
Redo Buffers 6303744 bytes
Database mounted.
Database Opened.
My question is why sqlplus is unable to find idle instance in oracle 11g to start them?
There was some configuration issue in /etc/hosts. IP was mapped against some different hostname, hence the issue. After mapping IP to correct Hostname issue got resolved.
Its very simply if your Database is already started up, sqlplus will connect to the instance. If instance is not started up, sqlplus will connect to an idle instance by default. Moreover if you want to connect with a specific instance you have to specify #SID_NAME as follows in the sqlplus command
sqlplus / as sysdba#SID
I've configured Oracle wallet successfully in my Linux server(Linux 2.6.32-642.4.2.el6.x86_64 GNU/Linux).
When I try to execute the below command using Database connection string, it works perfect.
$/sqlplus /#TESTDB
SQL*Plus: Release 11.2.0.3.0 Production on Tue Oct 18 07:12:49 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning option
SQL>
But, when I run the same command using sqlplus Instant Client, it's throwing the below error. Please help me to resolve this.
$ oracle/instantclient/11.1.0.6.0-ml01/.exec/x86-64.linux.2.6/bin/sqlplus /#TESTDB
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 18 07:14:38 2016
Copyright (c) 1982, 2007, Oracle. All rights reserved.
ERROR:
ORA-12534: TNS:operation not supported
Note:
Any way, When I use the Instant sqlplus client to connect using username and password, it works fine.
/oracle/instantclient/11.1.0.6.0-ml01/.exec/x86-64.linux.2.6/bin/sqlplus USERNAME/PASSWORD#TESTDB
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 18 07:16:46 2016
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning option
SQL>
You may have to recreate the wallet using the specific environment. For example, my oracle-11 client wallet doesn't work when I have an oracle-12 environment defined ... and vice versa. Neither of my client configs are instant clients, but I think the 'secure external password' (aka wallet) store is specific to the client.
I have installed an oracle 11g instance on a linux machine. After doing a DB bounce by issuing shutdown immediate and startup. Not able to login as sys/password#sid as sysdba. Even issued a
orapwd file=orapwsid password=password entries=30 force=y
command, which created a pwd file also.
But still not able to login as sys. I can connect to the DB by scott and other users created but not as a sysdba.
Request you to help me.
I got into same issue but did not know that I have to switch to oracle user to get dba access.
$ cd ORACLE_HOME/xe/bin
$ ls -la oracle
-rwsr-s--x 1 oracle dba 165700472 Aug 28 2011 oracle
$ su oracle
$ sqlplus sys as sysdba
You should be able to login without any issues
Make sure you are a dba!
[bb#limbo] ~/ $ . oraenv
ORACLE_SID = [XE] ? XE
ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID bb.
You can set ORACLE_BASE manually if it is required.
[bb#limbo] ~/ $ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 16 19:02:11 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
sys#XE> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
[bb#limbo] ~/ $ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 16 19:05:56 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-01031: insufficient privileges
Enter user-name:
[bb#limbo] ~/ $ su -c "usermod -G dba bb"
Password:
[bb#limbo] ~/ $ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 16 19:06:29 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
sys#XE>
I managed to resolved this issue by making sure the instance name case sensitive in listener file. Also the orapw file. If the SID are small case, I make sure all related files using the smaller case intance name.
> $ORACLE_HOME/bin/sqlplus as sysdba
this would work if your $ORACLE_HOME is set correctly
to check your $ORACLE_HOME run
> echo $ORACLE_HOME
this will display oracle home path