Pro*C/C++ and the goto operator

From: Alex Vinokur <alexander.vinokur_at_telrad.co.il>
Date: Mon, 04 Oct 1999 12:19:23 GMT
Message-ID: <7ta601$s8g$1_at_nnrp1.deja.com>


Hi,

Here is a piece of code from
[Quoted] file sample1.pc (Pro*C/C++ Demo).


    for (;;)
    {

[Quoted]         emp_number = 0;
        printf("\nEnter employee number (0 to quit): ");
        gets(temp_char);
        emp_number = atoi(temp_char);
        if (emp_number == 0)
            break;

/* Branch to the notfound label when the

  • 1403 ("No data found") condition occurs. */ EXEC SQL WHENEVER NOT FOUND GOTO notfound; // ATTENTION#1
        EXEC SQL SELECT ename, sal, comm
            INTO :emprec INDICATOR :emprec_ind
            FROM EMP
            WHERE EMPNO = :emp_number;


/* Print data. */
printf("\n\nEmployee Salary Commission\n"); printf("-------- ------- ----------\n");
/* Null-terminate the output string data. */
emprec.emp_name.arr[emprec.emp_name.len] = '\0'; printf("%s %7.2f ", emprec.emp_name.arr, emprec.salary); if (emprec_ind.comm_ind == -1) printf("NULL\n"); else printf("%7.2f\n", emprec.commission); total_queried++; continue; notfound: // ATTENTION#2 printf("\nNot a valid employee number - try again.\n");

    } /* end for(;;) */


This code uses the goto operator

        EXEC SQL WHENEVER NOT FOUND GOTO notfound and label (notfound).

The question is:

        Can we write (in Pro*C/C++)
        an equivalent program
        that does not use the goto operator?


===============================

Oracle8
SunOS 5.6

$ORACLE_HOME/precomp/demo/proc
sample1.pc


        Thanks in advance,
        Alex




Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Oct 04 1999 - 14:19:23 CEST

Original text of this message