0

Could anyone help me on resolving this error which I am getting when I try to run a shell script test.sh with parameter as 20211007 The code is as below:

#!/bin/sh

ODATE=${1}
file_source_sys="abc"
File_name="xyz"
file_deliver_time="20210218:12:56:76"

HOME_DIR="/var/tmp/Sneha"

source ~/env/INFORMATICA.env
source ${HOME_DIR}/db.properties

cd ${HOME_DIR}

cat <<EOD > temp.sql
INSERT INTO test VALUES 
('${file_source_sys}','${File_name}','${file_deliver_time}','$ODATE');

commit;

quit
EOD

sql ${USER}/\"${PASS}\"@${DB_INSTANCE} @temp.sql

The error is as below:

SQLcl: Release 18.3 Production on Sat Nov 06 18:53:24 2021 Copyright (c) 1982, 2021, Oracle. All rights reserved.

Last Successful login time: Sat Nov 06 2021 18:53:25 +01:00

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.11.0.0.0

Error starting at line : 1 File @ /var/tmp/Sneha/temp.sql In command - INSERT INTO test VALUES ('abc','xyz','20210218:12:56:76','20211005') Error at Command Line : 1 Column : 13 File @ /var/tmp/Sneha/temp.sql Error report - SQL Error: ORA-00942: table or view does not exist

Commit complete.

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.11.0.0.0

Note I double checked and confirmed that table test is created in DB. Also I manually checked my inserting this insert statement generated into DB it is working fine. But via Shell script it is not happening.

Also I see the temp.sql file is generated with below content:

INSERT INTO test VALUES ('abc','xyz','20210218:12:56:76','20211005');

commit;

quit

I am not sure where in the code I am going wrong, as I can see the script is connecting to database successfully and also doing commit and disconnecting itself as well properly.

Your help is much appreciated. Many thanks

4
  • 1
    Did you check that statement via SQL*Plus with the same credentials? Commented Nov 6, 2021 at 19:30
  • 1
    meta.stackoverflow.com/questions/333952/… Commented Nov 6, 2021 at 21:25
  • Given that you can connect and the Oracle error is quite clear, I can only imagine that you are using a different user or your user misses some privilege. What happens if you replace the insert with a select * from test;? Commented Nov 7, 2021 at 8:18
  • As a diagnostic test, how about having it print out the current instance and schema name? Commented Nov 7, 2021 at 19:13

2 Answers 2

0

Are you sure that you are connected to the right database, it says that the table 'test' doesn't exist, try doing:

INSERT INTO DB_NAME.test VALUES (...);
Sign up to request clarification or add additional context in comments.

1 Comment

I am connecting to a simulation database hence this error was coming, the actual schema and simulation schema are so much alike that I missed one one character in the hostname while connecting to actual schema. Many thanks for your suggestions. :)
0

I am connecting to a simulation database hence this error was coming, the actual schema and simulation schema are so much alike that I missed one one character in the hostname while connecting to actual schema. Many thanks for your suggestions. :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.