We have a procedure e.g. prc_synonym created in Oracle 12c Database. I want to do small change in procedure through Unix. I have that changed procedure (prc_synonym) in proc.sql file. Want to recompile that procedure through Unix so that changes should reflect in existing procedure in database.
I have tried below options:
Executing that sql by command @proc.sql
then Exec prc_synonym
But procedure is not getting recompiled , not able to see changes in database procedure.
I see nothing here to indicate this is a shell scripting issue. If you are connecting to the database with sqlplus, then submitting the script:
SQL> @proc.sql
And not getting the results you expect, then the problem is entirely in your sql script. You'd be much better off post to a forum at OTN. And when you do, save time by posting the code before some has to ask you to do so. No one can debug code they cannot see.
But just to address the immediate shell script question:
Like I said, it has nothing to do with your shell script.
You'd be far better off posting this (with the actual contents of proc.sql and any errors it throws) on the appropriate OTN forum: Space: SQL and PL/SQL | Oracle Community
If I take procedure code and execute on Toad, procedure is getting created successfully with no errors. I want this (to create procedure) through Unix.
I see nothing fundamentally wrong with the command you showed, though I would have done it. I'm not a fan of putting the password after the net service name. I showed you how I would have done it. If all you are doing is passing sqlplus the name of a script to execute, there is no reason to use input redirection.
In spite of your assertion that it works in Toad, I still believe it comes down to a problem with your sql script, not your unix code.
Can you debug code you cannot see?
Can you debug code with no error codes?
1) Are you connecting to the correct schema ("darwin_ext")?
2) Will the schema "darwin_ext" own the procedure "prc_synonym"?
3) Did you check that the procedure name in script "proc.sql" is not prefixed by a schema name?
4) If the procedure name in "proc.sql" is prefixed by a schema name, then did you check that it is "darwin_ext"?
5) Are you using "create or replace procedure prc_synonym" instead of "create procedure prc_synonym"?
6) Do you have a forward-slash character ("/") at the end of your procedure i.e. after the line with the "END;" statement in your script?
7) Did you add the command "show errors" after the end of the procedure and the forward-slash character ("/") ?
8) Did you ensure that the "show errors" command does not show any errors i.e. it returns "No errors."?
If the answer to all the above questions is "yes", then add the following query before and after the script execution in your Unix shell script and post the output here:
select object_type,
object_name,
status,
to_char(created, 'DD-MON-YYYY HH24:MI:SS') as created,
to_char(last_ddl_time, 'DD-MON-YYYY HH24:MI:SS') as last_ddl_time
from user_objects
where object_name = 'PRC_SYNONYM';
Very important - the object_name must be in uppercase.
Valid points, all. But completely off-topic for this forum. This is purely a question of how to compile a PL/SQL proc and zero to do with shell scripting. The OP really, really needs to take this question to OTN or OraFAQ.
Would have sufficed, but knowing that is an issue of knowing how sqlplus works, which some participants in this forum would know but it certainly wouldn't be in the body of "assumed knowledge" like it would on an Oracle forum.
Lesson for me: pay closer attention to the details. I should have caught the missing EOF.
Lesson for the OP: Don't make your scripts more complex than they need be. There are many situations where a here document is appropriate (I make extensive use of them) but this wasn't one of them.