I have a ksh script that runs as root ans issues several commands as a user differente from root as 'su <user> -c "command" ' . It works fine except for one step where the command executes sql statements. That command fails with ORA-20000.
Now the strangest thing, if I place a read command just before that su everything works fine. I've tried a sleep 10/20/30 instead of read and it didn't work.
This is supposed to be an automation script so it must not pause waiting for input from the user.
Can someone help?
ORA-20000 errors are generated by exceptions in stored procedures or other PL/SQL code. Check that first, maybe it's depending on some other background procedure. Also, are you reading from a file in a loop? Could be that the command for the database connection (sqlplus, or something else) is reading incorrect data from there.
Hello Pludi,
the exception comes from a PL/SQL procedure. I wonder how, without changing anything else other than putting "read" before the su command that ultimately runs that PL/SQL makes it work. I was thinking of something in the line of "the read command flushes the DBMS_OUTPUT buffer" but I have nothing to support this nor do I have a way to control this behaviour.