SAMGET

The SAMGET routine searches the database for a qualifying index record and returns it into user storage.
view
The SAMGET routine searches the database for a qualifying index record and returns it into user storage.
Calling Parameters
  • Address of record key and record area
  • Address of two-byte (halfword) record area length
  • Address of two-byte search type:
    • 'EQ' - Get Equal
    • 'LT' - Get Less Than
    • 'GT' - Get Greater Than
    • 'LE' - Get Less Than or Equal
    • 'GE' - Get Greater Than or Equal
  • Address of two-byte (halfword) area to return the actual length of record (optional).
Return Codes
Output Return Codes (general register 15):
  • 0
    Database successfully read
  • 4
    Record not found or end of file
  • 8
    Error reading index
Calling Example: Assembler
The following is an example using assembler:
. . . MVC GREC(32),=CL32' ' BEGIN WITH FIRST GCR GETREC CALL SAMGET,(GREC,GRECL,GTYPE,GRETL),VL GET NEXT RECORD CH 15,=H'4' CHECK RETURN CODE BE DBEOF BH DBERR . . Process GCR record . B GETREC GET NEXT INDEX RECORD . . . GREC DS CL(GCRLEN) STORAGE FOR GCR GRECL DC Y(GCRLEN) LENGTH OF GCR GTYPE DC C'GT' GET GREATER THAN GRETL DS H RETURN LENGTH OF GCR
Calling Example: COBOL
The following is an example using COBOL:
. . . 77 RTNCODE PIC S9(8) COMP. 77 GRECL PIC S9(4) COMP VALUE +464. 77 GTYPE PIC X(02) VALUE 'GT'. 77 GRETL PIC S9(4) COMP. 01 GREC. 05 GREC-KEY PIC X(36). 05 GREC-DATA PIC X(428). . . MOVE SPACES TO GREC-KEY. GETREC. CALL 'SAMGET' USING GREC, GRECL, GTYPE, GRETL. MOVE RETURN-CODE TO RTNCODE. IF RTNCODE > 4 GO TO DBERR. IF RTNCODE = 4 GO TO DBEOF. . . Process GCR record . GO TO GETREC.