Showing results for 
Search instead for 
Did you mean: 

Need to send message to connected SQL sessions

Occasional Advisor

Need to send message to connected SQL sessions


Before shutdown or anytime if I want to send message to connected SQL sessions, how can I do ?
Assume that some users connected from windows, some from Unix.
How can we send messages to all connected sessions. From which Oracle userid we have to run the script,
please provide me the script.

Graham Cameron_1
Honored Contributor

Re: Need to send message to connected SQL sessions

Oracle does not provide any way to do this and I can't think of any way to add it.
In any case, while some of the Oracle sessions may be interactive users who can receive messages, there may be other batch sessions, and sending a message to these would be meaningless.
At the unix level you could possibly identify users using ps and grep, but then again if you have more than one database on the same box, you would have to be very careful to pick out the required sessions.
Sorry I can't give any better news ;-(
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
malay boy
Trusted Contributor

Re: Need to send message to connected SQL sessions

well I never cross any oracle sql command to broadcast a message to user.On unix you can used wall or write command - provide you know user tty.
sorry couldn't be any help.

There are three person in my team-Me ,myself and I.
Honored Contributor

Re: Need to send message to connected SQL sessions


There is no broadcast facility like that. The clients connected to Oracle are vast and varied. What would it mean to broadcast to an application server? A client connected via sqlplus? Or forms?

Two things that can be done:

The client itself MUST be listening for such a message which could be sent using DBMS_ALERT (but not via DBMS_PIPES). DBMS_ALERT is a "broadcast" method (but the client must check and then display the message -- so SQLPlus would never participate in this). DBMS_PIPE is a point to point conversation.

The "dba" would just "exec dbms_alert.signal( 'some_alert', 'some_message' );" but if no one was listening to him, it would not matter. Each and every client would have had to of issued:

dbms_alert.register( 'some_alert' );

upon connecting and would periodically have to issue:

dbms_alert.waitone( .... );

to see if a message had been sent. There are asyncronous callbacks available in OCI (Oracles C Call level interface) but not in general.

B. Provided that:
- your clients are on Windows
- your network topology allows
- your IT-policy allows
you might want to try this:

select 'NET SEND '||machine||' Please log out from immediately! Administrator.' from v$session where type='USER';

...or if you want to use e.g. NT-usernames, use OSUSER instead of MACHINE.

Copy the result and paste it into command prompt. Users will see your message in a popup dialog box.

This works only in some specific environments, but I have used it successfully in several offices. Likewise, I have used this technique in several other scripts to dynamically build DML commands before issuing them.

hope this helps!
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)