6 64 2 C Examples

LANSA Open Guide

6.64.2 C Examples

C Example 1

Set characteristics for a select search:

BOOL fOK;

int  iSession;

fOK = LceSetSelectOptions(iSession, "*BACKWARDS,  *MAXREC25");

fOK = LceRequestSelect(iSession, "SURNAME, SALARY", "PSLMST", "", FALSE);

fOK = LceReceiveSelect(iSession, "PSLMST");

fOK = LceGetRecordCount(iSession, "PSLMST", &iRecords);

for (iCount=0; iCount < iRecords; i++)

{

         fOK = LceGetSelect(iSession, "PSLMST", iCount, "SURNAME, SALARY");

}

 

C Example 2

Lock a record during a fetch:

BOOL fOK;

int  iSession;

 

fOK = LceSetSelectOptions(iSession, "*LOCK");

 

fOK = LceSetFieldValue(iSession, "EMPNO", "12345");

fOK = LceFetch(iSession, "SURNAME, GIVENAME", "PSLMST", "EMPNO");

 

C Example 3

Use *RECEIVEIMMED to Select Records:

BOOL fOK;

int  iSession;

long lFlags;

 

fOK = LceSetSelectOptions(iSession, "*RECEIVEIMMED");

 

fOK = LceRequestSelect(iSession, "SURNAME, SALARY", "PSLMST", "", FALSE);

 

fOK = LceReceiveNextX(iSession,"",0,NULL,0);

 

fOK = LceGetFieldValueX(iSession, "SURNAME", strSurname, lFlags);

fOK = LceGetFieldValueX(iSession, "SALARY", strSalary, lFlags);

 

C Example 4

Use blocking by key:

BOOL fOK;

int  iSession;

fOK = LceSetSelectOptions(iSession, "*BLOCKBYKEY");

 

fOK = LceRequestSelect(iSession, "SURNAME, SALARY", "PSLMST", "", FALSE);

fOK = LceReceiveSelect(iSession, "PSLMST");

fOK = LceGetRecordCount(iSession, "PSLMST", &iRecords);

for (iCount=0; iCount < iRecords; i++)

{

         fOK = LceGetSelect(iSession, "PSLMST", iCount, "SURNAME, SALARY");

}