Solved

Call a procedure on command line

Posted on 2014-11-24
8
173 Views
Last Modified: 2014-12-24
I have the below procedure. how can i call it on the command line with sqlplus
0
Comment
Question by:gaurav sharma
  • 3
  • 3
  • 2
8 Comments
 

Author Comment

by:gaurav sharma
ID: 40463106
CREATE OR REPLACE PROCEDURE recomp IS
BEGIN
   FOR cur IN (SELECT object_name,
                      object_type,
                      owner
               FROM   all_objects
               WHERE  object_type IN ('PACKAGE',
                                      'PACKAGE BODY')
               AND    owner = 'TRON2000'
               --                 AND object_name like 'EM%'
               ORDER  BY object_name)
   LOOP
      BEGIN
         IF cur.object_type = 'PACKAGE BODY' THEN
            EXECUTE IMMEDIATE 'alter package "' || cur.owner || '"."' ||
                              cur.object_name || '" compile body';
         ELSE
            EXECUTE IMMEDIATE 'alter ' || cur.object_type || ' "' || cur.owner ||
                              '"."' || cur.object_name || '" compile';
         END IF;
      EXCEPTION
         WHEN OTHERS THEN
            NULL;
      END;
      --dbms_output.put_line('Recompiled: ' || cur.OBJECT_TYPE || ' ' ||
   --                   cur.owner || '.' || cur.OBJECT_NAME);
   END LOOP;
END;
/
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 250 total points
ID: 40463161
From SQL*Plus, it would be:

exec recomp;
0
 

Author Comment

by:gaurav sharma
ID: 40463173
If I were to put this call in a file would it be .sql ? and what would be the contents of a file ?
0
 
LVL 34

Expert Comment

by:johnsone
ID: 40463242
It would be one line:

exec recomp;

Then from within SQL*Plus, you would run that using

@<path_to_script>/<script_name>
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:gaurav sharma
ID: 40463455
This is the error I get:

 Failed to execute:  EXEC RECOMP
java.sql.SQLException: ORA-00900: invalid SQL statement
0
 
LVL 13

Assisted Solution

by:Alexander Eßer [Alex140181]
Alexander Eßer [Alex140181] earned 250 total points
ID: 40464155
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 250 total points
ID: 40464238
You stated multiple times that you were running from SQL*Plus, not java.

If you are really running from Java and not SQL*Plus, then use the documentation link provided by Alexander.
0
 
LVL 13

Accepted Solution

by:
Alexander Eßer [Alex140181] earned 250 total points
ID: 40464310
I agree with johnsone: please clarify whether you run this within SQLPLUS or Java! Otherwise we might not be able to help you and this could get quite confusing!

I assumed, you got this error upon a Java execution based on the Java exception:
java.sql.SQLException: ORA-00900: invalid SQL statement
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now