Comments

The SQL standard specifies two forms of comments: "--" to end of line or C-like "/*" to "*/" both of which are supported in RaimaDB SQL. For example, both types of comments are shown below in a commented version of the n_oldest_authors procedure.

create proc n_oldest_authors(
     in nrows smallint) -- number of result rows to be returned to caller
/*
    call n_oldest_authors(3);

    rowno full_name                                     author_age
        0 Hobbes, Thomas                                        91

    rowno full_name                                     author_age
        1 Sinclair, Upton                                       90

    rowno full_name                                     author_age
        2 Hardy, Thomas                                         88
*/
begin
    declare rowno smallint default 0;
    for -- result column names are implicitly declared as variables
        select full_name, if(yr_died = 0, year(current_date()), yr_died)-yr_born author_age
        from author order by 2 desc
    do -- loops thru the above select one row at a time
        select rowno, full_name, author_age;
        set rowno = rowno + 1;
        if rowno = nrows then
            leave; -- exits the 'do' loop
        end if;
    end for;
end;