Доступные версии документации

Приложение 6. Пример работы с двумя ядрами СУБД

#include "inter.h"
#if defined(VXWORKS)
#include "vxstart.h"
#endif

static void PrintErrorAndCloseChannel(TCBL * pCBL);
#if defined(VXWORKS)
 MainStart(c_select, 1024 * 32, UninitLinterClient)
#else
 int main()
#endif

    {
char name[] = "SYSTEM/MANAGER";
int Count;
TCBL Cbl;
printf("\n*** Table b must be created in one database ***\n");
memset(&Cbl, 0, sizeof(TCBL));
printf("Open channel to default mbx\n");
Cbl.PrzExe &= ~(M_OPTIMISTIC | M_SHARE | M_EXCLUSIVE); /* Autocommit */
memcpy(Cbl.Command, "OPEN", 4);
inter(&Cbl, name, NULL, NULL, NULL);
    if if (Cbl.CodErr)
        {PrintErrorAndCloseChannel(&Cbl);
return 1;
}
    Cbl.LnBufRow = sizeof(Count);
memcpy(Cbl.Command, "SLCT", 4);
inter(&Cbl, NULL, "SELECT count(*) from b;", NULL, &Count);
    If (Cbl.CodErr)
        { PrintErrorAndCloseChannel(&Cbl);}
    printf("Close channel\n");
memcpy(Cbl.Command, "CLOS", 4);
inter(&Cbl, NULL, NULL, NULL, NULL);


setenv("LINTER_MBX", "1254", 1);
inter_control(&Cbl, ICR_REREAD_ENV, NULL, 0);
memset(&Cbl, 0, sizeof(TCBL));
printf("Open channel to mbx 1254 \n");
Cbl.PrzExe &= ~(M_OPTIMISTIC | M_SHARE | M_EXCLUSIVE); /* Autocommit */
memcpy(Cbl.Command, "OPEN", 4);
inter(&Cbl, name, NULL, NULL, NULL);
    if (Cbl.CodErr)
        { PrintErrorAndCloseChannel(&Cbl);
return 1;
}
    Cbl.LnBufRow = sizeof(Count);
memcpy(Cbl.Command, "SLCT", 4);
inter(&Cbl, NULL, "SELECT count(*) from b;", NULL, &Count);
    if (Cbl.CodErr)
        { PrintErrorAndCloseChannel(&Cbl); }
    printf("Close channel\n");
memcpy(Cbl.Command, "CLOS", 4);
inter(&Cbl, NULL, NULL, NULL, NULL);
printf("done\n");
printf("\nEnd of work.\n");
return 0;
}
void PrintErrorAndCloseChannel(TCBL * pCBL)
    {
printf("\n");
if (strncmp(pCBL->Node, " ", MAX_NODE_LEN) != 0 && *pCBL->Node != 0)
        printf("* Linter server <%.8s>\n", pCBL->Node);
        printf("* Channel N %d\n", pCBL->NumChan);
printf("* Command [%.4s]\n", pCBL->Command);
printf("* Linter error: %ld\n", pCBL->CodErr);
    if (pCBL->CodErr >= 2000 && pCBL->CodErr < 3000)
        fprintf(stderr, " Line %hd position %hd\n", ((L_WORD *) (&pCBL->SysErr))[0], ((L_WORD *) (&pCBL->SysErr))[1]);
    else if (pCBL->SysErr)
        printf("* System error: %ld\n", pCBL->SysErr);
        memcpy(pCBL->Command, "CLOS", 4);
    /* Close channel */
inter(pCBL, NULL, NULL, NULL, NULL);
}

Заметили ошибку?
Выделите текст и нажмите Ctrl + Enter