aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbswer1.x
blob: edc044597e80d53d303392e3f881e0319c757fe9 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
include <tbset.h>
include "tbtables.h"

# tbswer1 -- write empty rows, maybe

# This routine is like tbswer with one significant difference.  If the row
# to be written (selrow) is equal to the current number of rows plus one,
# and if the table is an stsdas type row-ordered table, then this routine
# does NOT write an INDEF row to the table and does NOT update TB_NROWS.
# This is to improve efficiency for this common case, so that the row
# does not need to be written twice (once INDEF, then the actual data).
# Routines such as tbxap[] may take advantage of this option.
#
# For other cases, this routine just calls tbswer, which does write INDEF
# rows to the table and does update TB_NROWS.
#
# If a row selector is in effect, selrow will be converted to rownum, and
# new rows (if rownum is beyond EOF) will be added to the set of selected
# rows.  If there is no row selector, the value of selrow will be assigned
# directly to rownum.
#
# Phil Hodge,  4-Mar-1998  Subroutine created.

procedure tbswer1 (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
#--
errchk	tbsrow, tbswer

begin
	if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {

	    if (TB_ROW_SELECT(tp) == YES) {

		if (selrow > TB_NSEL_ROWS(tp) + 1)
		    call tbswer (tp, selrow, rownum)
		else
		    call tbsrow (tp, selrow, rownum)	# TB_NROWS not updated

	    } else {

		rownum = selrow
		if (rownum > TB_NROWS(tp) + 1)
		    call tbswer (tp, selrow, rownum)
	    }

	} else {

	    call tbswer (tp, selrow, rownum)
	}
end