Chapter Contents

Previous

Next
QUEUE_RECV

QUEUE_RECV



Receive message into variables.


Syntax
QUEUE_RECV Example 1
QUEUE_RECV Example 2

Syntax

CALL QUEUE_RECV(queueId, rc <, parm1,...,parmn>);

Where... Is type... And represents...
queueId N queue identifier
rc N return code
parm1,...parmn N or C parameters in which to receive the message surfaced by the query; consists of 0 or more numerics or characters

When a message is surfaced by a query, it must be received into either data set variables or macro variables, depending on whether it is invoked with a DATA step or as a macro. QUEUE_RECV supports the receipt of both numerics and characters. QUEUE_RECV must be called with the correct parameter types. For example, if a character and a numeric variable were sent to the queue, QUEUE_RECV must be called with a numeric and a character variable in the correct order.

If an error or a warning condition is encountered during the receive, a non-zero return code is returned in the rc parameter. Use the SYSMSG() function to print the message that is associated with the non-zero rc.

If an unexpected message is received, QUEUE_RECV can be called with no receive parameters in order to throw away the message. A truncation warning is returned, but the message will have successfully been thrown away.


QUEUE_RECV Example 1

This example queries on a fetch queue, and based on the msgtype that is returned, receives the message into the appropriate variables.

call queue_query(queueId, etype, msgtype, 
                 attachFlag, rc);

if (etype = "DELIVERY") then do;

      /**********************************/
      /* will have some meaning to user */
      /**********************************/
   if (msgtype = 1) then do;
      name = '';
      age = 0;
      race = '';
         /*******************************/
         /* receive 3 parameters        */
         /*******************************/
      call queue_recv(queueId, rc, name, 
                      age, race);
   end;
   else if (msgtype = 5) then do;
         /*******************************/
         /* receive 1 parameter         */
         /*******************************/
     task = 0;
      call queue_recv(queueId, rc, task);
   end;
   else do;
      /**********************************/
      /* unknown message type; throw out*/
      /* message by forcing truncation  */
      /**********************************/
      call queue_recv(queueId, rc);
   end;
end;


QUEUE_RECV Example 2

This example throws the message away by forcing truncation.

call queue_recv(queueId, rc);


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.