Chapter Contents

Previous

Next
FETCH

FETCH



Reads the next nondeleted row from a SAS table into the Table Data Vector (TDV)

Category: SAS Table


Syntax
Details
Example
See Also

Syntax

sysrc=FETCH(table-id<,'NOSET'>);

sysrc
contains the return code for the operation:
0 successful
>0 not successful
<0 the operation was completed, but a warning or a note was generated. If the row is locked, it is still fetched (read in) but a sysrc of _SWNOUPD is returned.
-1 the end of the table was reached
Type: Numeric

table-id
is the identifier that was assigned when the table was opened. If table-id is invalid, the program halts.

Type: Numeric

'NOSET'
prevents the automatic passing of SAS table column values to SCL variables even if the SET routine has been called.

Type: Numeric


Details

FETCH skips rows that have been marked for deletion. When a WHERE clause is active, the function reads the next row that meets the WHERE condition.

If the SET routine has previously been called, the values for any table columns that are also window variables or SCL variables for the application are automatically passed from the TDV to the SCL Data Vector (SDV). To temporarily override this behavior so that fetched values are not automatically copied to the SDV, use the NOSET option.


Example

Fetch the next row from the SAS table MYDATA. If the end of the table is reached or if an error occurs, SYSMSG retrieves the appropriate message and displays it on the message line.

INIT:
   tableid=open('mydata','i');
return;

MAIN:
   rc=fetch(tableid);
   if rc then _msg_=sysmsg();
   else
      do;
        ...more SCL statements...
      end;
return;

TERM:
   rc=close(tableid);
return;

See Also

APPEND

FETCHOBS

GETVARC and GETVARN

LOCATEC and LOCATEN

PUTVARC and PUTVARN

SET

UPDATE


Chapter Contents

Previous

Next

Top of Page

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