ftch2nd()

Purpose

Fetches a record using a secondary index. This function is regarded as obsolete in 4.500

Syntax

boolean ftch2nd(flags, datarec, indexrec, role, ADDITIONAL)

Parameters

int flags

Indicates the search method used

 

short* datarec

Pointer to the L field of table record to be read

 

short* indexrec

Pointer to the L field of an index table record

 

int role

Null-terminated string indicating the role

 

char* ADDITIONAL

Optional fields depending on value of flags

 

The parameter flags can take any of the values as for the function rec_fetch_main(). The parameters indexrec and role determine which index is to be used in the search. If the flag contains the use of NEXT, the parameter ADDITIONAL is used to specify the depth required.

Description

The function ftch2nd() fetches a record from the database using a secondary index. Note that the key data should be assigned to the datarec record not the indexrec table.

Return values

The return value indicates whether the read was successful or not. The program terminates if the index or the role is invalid, or for any of the reasons that the function rec_fetch_main() terminates.

See also

rec_fetch_main(), rec_fetch()

Example

/*
C Functions Reference Manual
----------------------------
Filename: FTCH2ND.C
Example: ftch2nd
Purpose: illustrate ftch2nd by fetching all
customer records.
*/
/*
#db salesord
#c
#libtype 1
#tables customer,
index_cust_name;
#end
*/
#include "dp4.h"
#include "ftch2nd.h"
/* generate this file by running LIBMAKE */
void process()
{
int srch = FIRST;
map_datamap(1);
while (ftch2nd(srch,&customer.l,
&index_cust_name.l,"") && !abort_code)
{
map_datamap(2);
show_c(2,1,customer.name);
show_n(2,2,customer.customer_number);
askf_special(2,3,0);
srch = NEXT;
}
}