Was this helpful?
Programming for Error Message Output
By default, all Ingres and forms system errors are returned to the EQUEL program, and default error messages are printed on the standard output device. As discussed in the QUEL Reference Guide, you can also detect the occurrences of errors by means of the program using the inquire_ingres and inquire_frs statements. Use the latter for checking errors after forms statements. Use inquire_ingres for all other EQUEL statements.
This section discusses an additional technique that enables your program not only to detect the occurrences of errors but also to suppress the printing of default Ingres error messages if you choose. The inquire statements detect errors but do not suppress the default messages.
This alternate technique entails creating an error-handling function in your program and passing its address to the Ingres runtime routines. Then Ingres will automatically invoke your error handler whenever an Ingres or a forms-system error occurs. Your program error handler must be declared as follows:
[global] function funcname (ingerr:Integer):Integer;
This function must be passed to the EQUEL routine IIseterr( ) for runtime bookkeeping using the statement:
IIseterr(%immed funcname);
This forces all runtime Ingres errors through your function, passing the Ingres error number as an argument. If you choose to handle the error locally and suppress Ingres error message printing, the function should return 0; otherwise the function should return the Ingres error number received.
Avoid issuing any EQUEL statements in a user-written error handler defined to IIseterr, except for informative messages, such as message, prompt, sleep, and clear screen, and messages that close down an application, such as endforms and exit.
The following example demonstrates a typical use of an error function to warn users of access to protected tables.
## program ErrorHandling(input, output);


    [global] function ErrorProc(ingerr: Integer) : Integer;
        TBLPROT = 5003;
    if (ingerr = TBLPROT) then begin
        writeln('You are not authorized for this operation');
        ErrorProc := 0;     { Suppress Ingres message }
    end else begin
        ErrorProc := ingerr; { Ingres will print message }
    end;                { ErrorProc }

## declare

## begin

##      Ingres dbname


        IIseterr(%immed ErrorProc);


##  end.                { ErrorHandling}
Last modified date: 06/10/2024