Chapter Contents

Previous

Next
_recv

_recv



Receive message into SCL variables.


Syntax
Example 1
Example 2

Syntax

CALL SEND(queueInst, '_recv', rc <, parm1,...,parmn>);

Where... Is type... And represents...
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 needs to be received into SCL parameters. _recv supports the receipt of numerics and characters. SCL lists are not supported by _recv; _recvlist should be called to receive SCL lists. _recv must be called with the correct parameter types. For example, if a character and a numeric variable are sent to the queue, _recv must be called with a numeric and a character variable in the correct order.

If an error or warning condition is encountered during the receive, a non-zero return code is returned in the rc parameter. The return codes shown here are a defined set of warning or error conditions that can be checked by using the %SYSRC macro, which is provided in the autocall library that is supplied by SAS Institute.

If the rc is not one of the messages shown here, use SYSMSG() to determine the exact error message.

_SWTRUNC
is a WARNING that indicates that the message has been truncated because too few parameters were passed into the _recv method. All parameters that were passed into the method are updated, but the remainder of the message is truncated.

_SENOBUF
indicates that the receive failed because there is no message to receive.

_SEMORE
indicates that the receive failed because more receive parameters (parm1...parmn) were passed into _recv than were actually received. Parameters are NOT updated and _recv needs to be called again to receive the message.

If an unexpected message is received, _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.


Example 1

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

header = makelist();
attachlist = makelist();
call send(queueInst, '_query', etype, msgtype,
          header, attachlist, rc);

if (etype = "DELIVERY") then do;

   if (msgtype = 1) then do;
      name = '';
      age = 0;
      race ='';
         /* receive 3 parameters */
      call send(queueInst, '_recv', rc, 
                name, age, race);
   end;
   else if (msgtype = 5) then do;
         /* receive 1 parameter */
      task = 0;
      call send(queueInst, '_recv', rc, task);
   end;
   else do;
         /* unexpected message, force */
         /* truncation                */
      call send(queueInst,'_recv', rc);
   end;
end;


Example 2

This example throws the unexpected message away by forcing truncation.

call send(queueInst, '_recv', rc);


Chapter Contents

Previous

Next

Top of Page

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