Recompile PL/SQL Procedure through UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Recompile PL/SQL Procedure through UNIX
# 1  
Old 08-18-2017
Recompile PL/SQL Procedure through UNIX

Hi,

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:
1. Executing that sql by command @proc.sql
2. then Exec prc_synonym

But procedure is not getting recompiled , not able to see changes in database procedure.

please guide us on this asap.

Thanks in advance.
# 2  
Old 08-18-2017
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:

Code:
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:

Code:
#!/bin/sh
sqlplus username/password@mydb  @proc.sql

This User Gave Thanks to edstevens For This Post:
# 3  
Old 08-18-2017
Thanks for your reply.

i have below unix code to connect to DB :

Code:
/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/sqlplus -s darwin_ext@SRCDBCA/Da3w1n\#E5t << EOF  
  @proc.sql


proc.sql having procedure block (create or replace procedure).

But that procedure is not getting created in database through above Unix code.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 08-18-2017 at 09:28 AM.. Reason: Added CODE tags.
# 4  
Old 08-18-2017
Quote:
Originally Posted by Aparna.N

But that procedure is not getting created in database through above Unix code.
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
# 5  
Old 08-18-2017
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.
# 6  
Old 08-18-2017
Quote:
Originally Posted by Aparna.N
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?

Neither can anyone else.
# 7  
Old 08-18-2017
Quote:
Originally Posted by Aparna.N
...
i have below unix code to connect to DB :

Code:
/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/sqlplus -s darwin_ext@SRCDBCA/Da3w1n\#E5t << EOF  
  @proc.sql

proc.sql having procedure block (create or replace procedure).

But that procedure is not getting created in database through above Unix code.
...
...
You may want to check a few things:

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:

Code:
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.

Last edited by durden_tyler; 08-18-2017 at 10:46 AM..
This User Gave Thanks to durden_tyler For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Emailing results of a pl sql procedure from UNIX shell script

Hello All, I am writing the below unix script to email the result of a small pl sql procedure: #!/bin/bash ORACLE_HOME=/opt/oracle/orcts/product/9.2.0; export ORACLE_HOME SQLPLUS=$ORACLE_HOME/bin/sqlplus sqlplus -s user/pass@Db_instance<<EOF set echo off set feedback off set pages 0... (9 Replies)
Discussion started by: Bunty bedi
9 Replies

2. Programming

PL/SQL - one procedure for business logic

Hello, I need some advice how to to create one big transactional table. My table has following columns person_id, trans_id, date, dep_id, material_id, input, outpu, total I created procedure from which I will enter all transaction into that table. Problem is I don't have any idea how... (3 Replies)
Discussion started by: solaris_user
3 Replies

3. Programming

Sql Procedure in Pro C file

Hi, Can any one help me how to write a sql procedure in a pro *c file for selecting the data from a database and inserting the rows into a queue in a .pc file. thanx in advance. (1 Reply)
Discussion started by: jhon1257
1 Replies

4. Shell Programming and Scripting

calling pl/sql procedure from shell and return values

How could I call an Oracle PL/SQL procedure from any shell (bash) and catch returning value from that procedure (out param) or get a returning value if it's a function. also, I got into trouble when I tried to send a number as a param #!/bin/bash -e username=$1 pwd=$2 baza=$3... (0 Replies)
Discussion started by: bongo
0 Replies

5. Programming

Help with pl/sql stored procedure

Hi, Can anyone please let me know where to check if a particular stored procedure exists. If the procedure exists I want to display some message and if the procedure does not exists i want to exit with error message. checking from dba_objects doesnt help. suprisingly the procedure i... (3 Replies)
Discussion started by: justchill
3 Replies

6. Shell Programming and Scripting

How to compile a stored procedure that is there with in a script file(.sql) in unix

Hi, How can i compile the procedure code that is there in a script file (.sql) in unix. (0 Replies)
Discussion started by: krishna_gnv
0 Replies

7. Shell Programming and Scripting

calling a PL/SQL stored procedure from KSH

Hi I have a stored procedure which should be called from KSH. Could ayone please help me with this. Thanks (1 Reply)
Discussion started by: BlAhEr
1 Replies

8. UNIX for Dummies Questions & Answers

Running PL/SQL procedure via unix

All, I have a 10g PL/SQL procedure that needs to be run via a unix script. How could such a script be developed. Thanks Aditya. (1 Reply)
Discussion started by: kingofprussia
1 Replies

9. UNIX for Advanced & Expert Users

How to call SQL procedure from UNIX Shellscript ?

Hi All I would be thankful to you all if you will guide me the steps to call a stored proc. from unix shell script. that stored proc. could be parameterised or parameterless developed in SQL. Any info. in this topic would help me..... Thanks in advance.... (1 Reply)
Discussion started by: varungupta
1 Replies

10. Shell Programming and Scripting

return variable from PL/SQL procedure to shell

Hi i'm calling a pl/sql procedure which is returning one variable. i'm trying to assing this value to variable in shell script the code i wrote is ** in shell script** var= 'sqlplus user/pass @ret.sql' echo $var ** and variable dum_var number exec rt_test(:DUM_VAR); exit; in... (4 Replies)
Discussion started by: ap_gore79
4 Replies
Login or Register to Ask a Question