Executing OS Commands from inside PL/SQL
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Executing OS Commands from inside PL/SQL

  1. #1
    Join Date
    Nov 2000
    Posts
    42

    Question

    Hello.

    I'm trying to execute the "dir" command from inside my PL/SQL script.

    If I perform this within SQL*Plus, it's works:

    SQL> host dir;

    But if I write "host dir;" inside my PL/SQL script, I get this error message:

    PLS-00103: Encountered the symbol "dir" when expecting one of the following: := . ( @ % ;

    Can I execute OS commands from my PL/SQL script?

    Regards.
    ========
    LARRY ELLISON

  2. #2
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,684
    HOST is an SQL*Plus command, not a PL/SQL command. To run host commands from PL/SQL you need to use a Java stored procedure or a shared library via EXTPROC. Java is the easiest option:

    http://www.oracle-base.com/Articles/...sFromPLSQL.asp

    If you want to return host output consider using something like:

    http://asktom.oracle.com/pls/ask/f?p...0_P8_DISPLAYID,F4950_P8_CRITERIA:3069633370832,%7Bshell%7D%20and%20%7Bcommands%7D%20and%20%7Bfrom%7D%20and%20%7BPL %2FSQL%7D

    Cheers
    Tim...
    OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
    OCA PL/SQL Developer
    Oracle ACE Director
    My website: www.oracle-base.com
    My blog: www.oracle-base.com/blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width