Link to home
Start Free TrialLog in
Avatar of gaurav sharma
gaurav sharma

asked on

Call a procedure on command line

I have the below procedure. how can i call it on the command line with sqlplus
Avatar of gaurav sharma
gaurav sharma

ASKER

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;
/
SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If I were to put this call in a file would it be .sql ? and what would be the contents of a file ?
It would be one line:

exec recomp;

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

@<path_to_script>/<script_name>
This is the error I get:

 Failed to execute:  EXEC RECOMP
java.sql.SQLException: ORA-00900: invalid SQL statement
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial