[Info-ingres] labels on a while statement

Roy Hann specially at processed.almost.meat
Wed Jul 3 13:43:51 UTC 2019


Martin Bowes wrote:

> Hi All,
>
>>From the SQL manual:
>
> A WHILE statement can be labeled. The label enables the ENDLOOP statement to break out of a
> nested series of WHILE statements to a specified level. The label precedes WHILE and is
> specified by a unique alphanumeric identifier followed by a colon, as in the following:
> A: WHILE...
> The label must be a legal object name...
>
> So why is it that the label can only be a single alphanumeric character? Anything other 
> than a single character causes a syntax error.

The problem (I believe) is that OUTER is a keyword. They can often be
used for identifiers with impunity, but sometime not. 

This works:

create procedure weird_label
as declare
    loop integer4 not null not default;
    msg varchar(256) not null not default;
begin
    loop = 0;
    Marty: while (:loop < 3) do
        msg = 'Loop ' + varchar(:loop);
        message :msg;
        loop = loop + 1;
    endwhile;
    msg = 'Finished with loop = ' + varchar(:loop);
    message :msg;
end; 

--Roy



More information about the Info-ingres mailing list