| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Pro*C/C++ and the goto operator
Hi,
Here is a piece of code from
file sample1.pc (Pro*C/C++ Demo).
for (;;)
{
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
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?
===============================
$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 - 07:19:23 CDT
![]() |
![]() |