Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2013
    Posts
    19

    Unanswered: How to execute Unix Command in PL/SQL

    Hi All,

    Is anyone can guide / know how to execute Unix Command in PL/SQL ?
    Below is the sample program.

    Appreciate anyone can help or guide. Thanks.


    CREATE OR REPLACE PROCEDURE P_ARCHIVE_FILE

    IS EXC_MESSAGE EXCEPTION;

    BEGIN

    -- Zip abc.txt to abcYYYYMMDD.txt
    HOST('mv abc.txt abc20131231.txt');
    HOST('gzip abc20131231.txt');

    END;

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    There is a difference between SQL, PL/SQL, & SQL*plus.

    "HOST" is a SQL*Plus command.

    To do as you desire utilize EXTERNAL PROGRAM or Java
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Nov 2003
    Posts
    2,932
    Provided Answers: 12
    This is possible through the dbms_sheduler package and using the job_type = 'EXECUTABLE'

    More details are in the manual: http://docs.oracle.com/cd/E11882_01/...d.htm#i1000363

    And here is an example: http://stackoverflow.com/a/1059458/330315
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  4. #4
    Join Date
    Jan 2013
    Posts
    19
    Quote Originally Posted by anacedent View Post
    There is a difference between SQL, PL/SQL, & SQL*plus.

    "HOST" is a SQL*Plus command.

    To do as you desire utilize EXTERNAL PROGRAM or Java
    hi anacedent, I want purely use PL/SQL to call unix command. Is it possible??

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    I want purely use PL/SQL to call unix command. Is it possible?

    Let me google that for you
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  6. #6
    Join Date
    Nov 2003
    Posts
    2,932
    Provided Answers: 12
    Quote Originally Posted by weicia View Post
    I want purely use PL/SQL to call unix command. Is it possible??
    See my answer
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

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