tags:

views:

33

answers:

2

First, I am creating an executable job:

BEGIN
  DBMS_SCHEDULER.CREATE_JOB(job_name => 'PIPE_JOB', job_type => 'EXECUTABLE', job_action => 'RMAN PIPE TEST_PIPE_1 target / TIMEOUT = 60');
END;

Next, I am trying to execute the job with this series of Oracle commands:

DECLARE
  pipename CONSTANT VARCHAR2(100) := 'TEST_PIPE_1';
  create_result INTEGER;
  send_result INTEGER;
BEGIN
  create_result := DBMS_PIPE.CREATE_PIPE(pipename);
  DBMS_PIPE.PACK_MESSAGE('BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DEVICE TYPE DISK DATABASE INCLUDE CURRENT CONTROLFILE;');
  send_result := DBMS_PIPE.SEND_MESSAGE(pipename);
  DBMS_SCHEDULER.RUN_JOB(job_name => 'PIPE_JOB', use_current_session => false);
END;

Now, when I make the call to RUN_JOB, the RMAN executable fires up on the server, but then immediately exits, presumably because it never receives the commands that I am attempting to pack into the pipe.

How can I use pipes correctly to make RMAN receive the commands I am trying to send it?

+1  A: 

I don't think you can use DBMS_PIPE for this. It is a PL/SQL 'thing' and not something RMAN can deal with, and not like unix pipes to STDIN.

You can do parameters with DBMS_SCHEDULER though. You may need an intervening shell script.

[Added] I'd have a shell script that takes one or more parameters

dbms_scheduler.create_job
(
job_name => 'job1',
job_type => 'EXECUTABLE',
job_action => '/somewhere/rman_script.sh',
enabled => false,
number_of_arguments => 2,
comments => 'Run shell-script'
);
dbms_scheduler.set_job_argument_value(SHELL || jobidx,1,'blah');
dbms_scheduler.set_job_argument_value(SHELL || jobidx,2,'blah');
dbms_scheduler.enable('job1');

The shell script would call RMAN and pipe the parameters to it through STDIN.

Gary
When you say "You can do parameters", what exactly do you mean? I can add command line parameters to the executable when I create the job? And where would I need a shell script? (I am very new to all things Oracle)
Raggedtoad
+1  A: 

Looks like I was wrong before and RMAN can be used with DBMS_PIPE. Article here. Don't understand it myself, but a comment on the blog may give some more details

Gary
Thanks for re-visiting the question! I'll definitely take a look at this article.
Raggedtoad