Using DBMS_PIPE

Hi all,
I have a stored proc which generates a csv file from a table's data . Once the csv is generated, I have to move the file to a new location and send out an email.
I have a Unix script which can move a given file and send an email.
I am trying to use DBMS_PIPE to invoke the Unix shell script, however the script is not executing - though the value of status is 0 below:-
Am I missing something? Pls suggest.
create or replace
procedure host(cmd in varchar2)
as
    status number;
begin
    dbms_pipe.pack_message(cmd);
    status := dbms_pipe.send_message( 'HOST_PIPE' );
    dbms_output.put_line('status is: '||status);
    if ( status <> 0 ) then raise_application_error( -20001, 'Pipe error' );
    end if;
end;I have tried to make sense of documentation about this - but couldnt grip the concepts fully.
Edited by: Chaitanya on Mar 28, 2011 9:53 PM

Hi Chaitanya,
Can you please try this below code , instead of that.
CREATE OR REPLACE PROCEDURE host (cmd in VARCHAR2) AS
status NUMBER;
BEGIN
DBMS_PIPE.PACK_MESSAGE(LENGTH(cmd));
DBMS_PIPE.PACK_MESSAGE(cmd);
status := DBMS_PIPE.SEND_MESSAGE('HOST_PIPE');
dbms_output.put_line('status is: '||status);
IF status == 0 THEN
raise_application_error(-20001, 'Pipe error');
END IF;
END host;
Hope it will help you :)
Thanks,
Balaji K.

Similar Messages

  • Error geting while using DBMS_PIPE

    following package use DBMS_PIPE procs
    CREATE OR REPLACE package body OE.work_on_pipe
    is
    procedure write_local_pipe
    is
    message varchar2(30);
    begin
    message:='rahul';
    dbms_pipe.reset_buffer;
    dbms_pipe.pack_message(message);
    dbms_output.put(message||' write on local buffer');
    end;
    procedure read_local_pipe
    is
    message varchar2(30);
    begin
    dbms_pipe.unpack_message(message);
    dbms_output.put(message||' read from local buffer');
    end;
    end;
    m getting error on line
    dbms_pipe.pack_message(message);
    Error messaage displayed as
    Probe:Exception raised in DBMS_DEBUG package
    anybody knows whts this error?
    Thanks in advance
    Rahul

    are you getting this error during compilation or during execution, because i am not getting any problems when i am compiling
    And also please let us know from where you are executing this, from sqlplus or from toad or from other tools

  • Problems using DBMS_PIPE package

    Hi! Im using the SQL Navigator for Oracle to develop PL/SQL code and now I've got a problem with the DBMS_PIPE package. When i use the methods like create_pipe etc. in a normal pl/sql window it works without problems. But when i place such a DBMS_PIPE.CREATE_PIPE... call into a function in my own pl/sql package there's the error PLS-00201: identifiere 'sys.dbms_pipe' must be declared!
    what do i have to do to use the dbms_pipe package in a package developed by my own.
    thanks in advise
    Ingo

    login to your SYS schema and grant execute on the DBMS_PIPE package to the oracle user under which you
    are creating your PL/SQL procedure:
    SQL> grant execute on SYS.DBMS_PIPE TO <username> ;

  • How to use dbms_pipe to execute a shell program

    Hi ,
    I have a stored procedure....with an if else condition in it
    what i want is
    if condition is true... then
    execute the shell script
    else
    do nothing
    how do i achieve this ? how do i execute a shell script from with in stored proc .. i heard dbms_pipe can be help ful ..could any one throw more light or an example to achieve this?

    learning_man wrote:
    sure i have gone through that option... but the thing is that.....i wnat to run the shell script only if a certain condition inside the stored proc passed some thing like
    if condition = true then
      dbms_scheduler.create_job(
      job_name   => 'TESTSH',
      job_type   => 'EXECUTABLE',
      job_action => '/mydir/myscript.sh',
      start_date => SYSTIMESTAMP,
      enabled    => TRUE,
      comments   => 'testsh');
    else
    dont do anything...
    end if;
    where as scheduler is used to schedule .... the time... i dont want to schedule the time.... i want to run the shell script based on some condition becoming true inside the procAbove code snippet does exactly what you're talking about.
    Max
    http://oracleitalia.wordpress.com

  • Running OS command using DBMS_PIPE

    Hi,
    I have reproduce the exemple in the documentation DBMS_PIPE - Example 3: Execute System Commands using the proc daemon.pc. It works, the commands are getting executed, but I have no control over them. What I need is for the calling PL/SQL function to wait for the OS command to finnish before continuing with the execution the PL/SQL function.
    Any hint would be appreciated. Thanks.

    odie_63 wrote:
    Justin Cave wrote:
    The normal way to approach that sort of requirement would be to use a Java stored procedure.Or a DBMS_SCHEDULER external program with "use_current_session" set to true.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1013568
    On 10g+ I'd definitely give this a go.

  • Dbms_Pipe Package.

    Hi,
    Can any one please tell me for which perpus we have to use dbms_pipe package.Please give one simple example.
    Thanks,
    Sanjeev.

    user13483989 wrote:
    Can any one please tell me for which perpus we have to use dbms_pipe package.Please give one simple example.For the same reason pipes are used when writing code that runs directly on the operating system (instead inside Oracle) - IPC or Inter Process Communication.
    See http://en.wikipedia.org/wiki/Inter-process_communication for basic details.

  • Dbms_pipe error

    hi all,
    we are using dbms_pipe with our application and sudenly we are gettinmg the below error.
    Sun Feb 05 08:25:13 2012 trnsfr_get_list: ORA-20001: Send Timeout on pipe ORA$PIPE$00E2CB3E0001Any Comments please..
    Edited by: user8792751 on 05-Feb-2012 23:44

    Any Comments please..My Comments:
    1). You haven't included any relevant information (such as version, platform, how you are using pipes, etc)
    2). http://bit.ly/zIpos4

  • Dbms_pipe

    hi,
    iam looking at logging event with trigger concept ,in that trigger use dbms_pipe to send the message , but i am confused where send has been send . please tell me for what purpose logging events and use of dbms_pipe.

    797525 wrote:
    iam just student when i going through the triggers concept i found event logging ,message has been send through the dbms_pipe ,let me write code.,I'm guessing this is a rather old book. It wouldn't make sense to use DBMS_PIPE for this sort of thing in any reasonably modern system.
    but if i run this query
    errrors shows that declare dbms_pipe error.Most likely, whatever user owns the trigger does not have access to the DBMS_PIPE package. The DBA would need to grant the user EXECUTE access on DBMS_PIPE for this code to compile.
    and you ask me about log file on database or flat file i really don't know
    if it is how to view in log file ,where it will be located if oracle 10g.Without some other process that is listening on the same port and unpacking the messages, this call to DBMS_PIPE won't be written anywhere. It would be lost at a minimum when Oracle shut down. You'd need to have something like an external application that knows to look for a pipe named INV_PIPE and to pull messages from that pipe. That external application would have to write the message somewhere that you could see it.
    Justin

  • DBMS_PIPE FOR IN-HOUSE CHATTING

    hi everybody!
    i wanted to know if i could use dbms_pipe package for making an application for chatting between different users simultaenously

    It is probably possible to get this to work, but it may be more painful that the alternatives...
    If you have a long-runing process, Oracle provides a view to let you monitor its progress v$session_longops. You can use the DBMS_APPLICATION_INFO package to record user-defined information into this view. Oracle Enterprise Manager has a nice interface for displaying the information in this view with a progress bar that you might be interested in mimicing in your application.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Dbms_pipe / maxpipesize / locking

    i use dbms_pipe in an application for debugging in development environment:
    this environment consists of the following parts:
    1) oracle server with plsql application and dbms_pipe for debug messages (SEND_MESSAGE)
    2) windows service with odp.net waiting for messages from pipe (RECEIVE_MESSAGE) servicing multiple clients over telnet connection (broadcasts the debug message from pipe on all clients connected with telnet)
    everything works fine - but some questions are open:
    my sending pipe func looks like following:
    create or replace PROCEDURE "DEBUG" (p_mandnr number, p_msg varchar2, p_type number) as
    v_status number:=0;
    v_lockHandle varchar2(200);
    begin
    dbms_lock.allocate_unique('control_lock', v_lockHandle);
    v_status := dbms_lock.request(v_lockHandle, dbms_lock.x_mode);
    if v_status=0 then
    if v_status=0 then
    dbms_pipe.pack_message(length(p_msg));
    dbms_pipe.pack_message(p_msg);
    dbms_pipe.pack_message(p_mandnr);
    dbms_pipe.pack_message(p_type);
    v_status := dbms_pipe.send_message('plsql_debug',0,1000000000);
    if v_status<>0 then
    dbms_pipe.purge('plsql_debug');
    v_status:=dbms_pipe.remove_pipe('plsql_debug');
    end if;
    end if;
    v_status := dbms_lock.release(v_lockHandle);
    end if;
    exception
    when others then
    case sqlcode
    when -6558 then -- ORA-06558: buffer in dbms_pipe package is full. No more items allowed
    dbms_pipe.reset_buffer;
    else
    null;
    end case;
    v_status := dbms_lock.release(v_lockhandle);
    end;
    1) do i have do lock the access to the pipe ?
    2) if i specify a maxpipesize in the SEND_MESSAGE call with an implicity created pipe - what happens, if the message length is less than maxpipesize
    3) what happens, if the windows service (RECEIVE_MESSAGE) do not run (so is not consuming messages from pipe), but the oracle server is writing messages to the pipe:
    - the pipe gets an overflow ?
    - if maxpipesize is reached the pipe is purged?
    - if sending is blocked, so the SEND_MESSAGE returns immediately or waits for free space in the pipe (HORROR - so the entire application would be blocked)
    - is there a life-timeout for messages in the pipe ?
    thx for helping

    You are able to execute it using an anonymous block because you have the execute privilege via a role. To be able to create procedures with it, you must be granted the execute privilege on SYS.DBMS_PIPE directly, not via a role.
    So log in as SYS, execute "grant execute on dbms_pipe to <your user>" and you are able to create your own procedures with dbms_pipe.
    Groet,
    Rob.

  • Running sql or perl script using DBMS_JOB

    Hi,
    Is there a way to run a sql or perl script using DBMS_JOB procedures? I have a perl script which checks out the table usage and emails the report to specific users. I want to run this script in a job scheduler, where I am using dbms_job to add the job. Please help. Any suggestions are greatly appreciated. Thanks.
    -Kristine

    You cannot run sql or perl scrips using DBMS_JOBS. You can run only Oracle procedures, functions, packages with DBMS_JOBS. They have to be stored in the database. You will have to create a Pro*C program that is listening on the pipe and push data to that pipe by using dbms_pipe. Then you can execute anything you want.

  • Dbms_pipe to send messages to a specified user?

    hi ,
    how can we use dbms_pipe to send a message to a specific user
    thanks
    kedar

    yes, why not...
    $ while : ; do mail [email protected] < pipename ; done
    of course this is just for demo, you should rather write a deamon in c if you want that.
    you can actually send anything to a pipe, and let any program execute/mail/evaluate/... the content

  • Retrieving messages - FIFO when using Correlation ID

    Hi,
    I've implemented a dbms_pipe clone using AQ (we're using RAC which doesn't support dbms_pipe - long story). Basically I've simulated dbms_pipe message queues by using CorrelationID's.
    Unfortunately, it seems that when retrieving a message by CorrelationID, the order is undetermined. It is critical in my scenario that messages are dequeued in the order they were enqueued.
    Does anyone have a trick or suggestion to solve my dilemma.
    Thanks,
    Steve

    Thanks for the reply. I should have explained myself a bit better. We had a number of existing apps that were developed using dbms_pipe. When we migrated to 11g RAC, of course everything broke.
    So I built a package that provides an identical interface to dbms_pipe but uses dbms_aq under the covers (which is RAC-friendly).
    I need to use the CorrelationID because I am implementing multiple 'logical' queues (similar to the dbms_pipe functionality) inside a single AQ queue. Messages are tagged with a CorrelationID which represents the logical queue.
    If there are multiple messages for a logical queue, calling the dequeue method with a CorrelationID (logical queue) does not necessarily retrieve the messages in FIFO order. On re-reading the documentation I see this is the expected (but in my case undesirable) behaviour.
    I hope this explains my dilemma a bit better :-).
    Thanks,
    Steve

  • DBMS_PIPE with RAC

    Hi
    I am trying using DBMS_PIPE within multiple instances of RAC ..but theres seems to be some issue....My version is 9206 .
    Is there any issue using pipes in RAC...plz help and any workaround
    Gagan

    i still have the same problem
    i have load balance on server and client site
    When i run my app and log on RAC1 and then when i run report, my app start another session (progres bar).
    If this session log on RAC1 then every thikn works fine, but sometime this session log on RAC2, and my progres bar dosn't work. Hi dont get message from first session.
    How can i resolve this?
    Ultimately i turn off load balance on server site and in application i will be redirect new connection to correct server?
    Thanks in advice

  • DBMS_JOB & DBMS_PIPE to mimic multithreaded application

    I am trying to use the DBMS_PIPE and DBMS_JOB PL/SQL packages (in 8i)
    to write a multithreaded Oracle package.
    By what I understand, the psuedo-code for my main and child procedures
    would be something like:
    PROC 1
    - Setup DBMS_PIPE package to receive messages
    - Spawn other procedure (PROC 2) multiple times using DBMS_JOB
    - Recieve messages from spawned procedures using DBMS_PIPE
    END PROC 1
    PROC 2
    - Do processing
    - Send message to PROC 1 using DBMS_PIPE
    END PROC 2
    What I would like is any examples of working code that anyone may have
    that can do just this. It does not appear too difficult but it's
    easier to work from an example givin that I have not done this before.
    Thanks
    Paul

    ..i would see that more as a candidate for using
    advanced queuing .. than dbms_job nor _pipe
    by using different queue tables
    ..its more easy i think and maybe more stable ..;)
    Matthias

Maybe you are looking for

  • Hdmi to vga connection using apple tv-2

    how can we connect apple tv-2 to a vga projector? what should we use? can we use an hdmi to vga adapter sold separately?

  • How to send a large email

    I am trying to email a newsletter as an attachment.  The newsletter has several photos in it, and my verizon email says that it is too big to send. I have tried to compress the file, zipping it, but it doesn't reduce the size very much. Am I doing so

  • SAP DB  changing the Log mode to the "Owerwrite mode is ON"

    Hi! I would like to know, which consequences do I have, changing the Log mode to the "Owerwrite mode is ON". Is that comparable with Oracle's archive mode? What should I note proccessing so (e.g. to make back up) I don't use the system in productive

  • Use Get-ADUser to get locked status and if locke give a choice to unlock it.

    Hi guys and girls, Im startling to learn powershell scripting and have made my first tool/Script. Below script is the one i use, however i do have an problem i would like some help with. I use the script to display some basic info and also to show if

  • Invoice Verification and valuated blocked stock

    Hi, We are using movement types 107 / 109 for modeling stock in transit. And we have trouble in invoice entry processing. We perform a good receipt with movement type 107 (Valuated Blocked Stock), but no 109 (storage receipt) is performed, when enter