aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbsirow.x
blob: 8129df52ebf387eb76091ef0b3ac0532cf240d16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
include "tbtables.h"
include "tblerr.h"

# tbsirow -- get actual row number from selected row number
#
# This routine is for translating the selected row number to the actual
# row number for an input table, i.e. for the case where the row number
# may not be greater than the number of rows in the table.

procedure tbsirow (tp, selrow, rownum)

pointer tp		# i: pointer to table descriptor
int	selrow		# i: row number (or selected row number)
int	rownum		# o: actual row number
#--
int	rst_rownum()

begin
	if (selrow < 1)
	    call error (1, "row number less than one is invalid")

	if (TB_ROW_SELECT(tp) == YES) {

	    if (selrow > TB_NSEL_ROWS(tp))
		call error (ER_TBBEYONDEOF, "input row is beyond EOF")

	    rownum = rst_rownum (TB_ROWSET(tp), selrow)

	} else {

	    if (selrow > TB_NROWS(tp))
		call error (ER_TBBEYONDEOF, "input row is beyond EOF")

	    rownum = selrow
	}
end