text: CREATE OR REPLACE PROCEDURE GETLINEERR
      (IN YINT DECIMAL,
       IN SLOPE DECIMAL,
       OUT TOTALERROR DECIMAL(12,3))
    LANGUAGE SQL
  BEGIN
    DECLARE XPT DECIMAL(20,16);
    DECLARE YPT DECIMAL(20,16);
    DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
    DECLARE C1 CURSOR FOR SELECT X_NUM,Y_NUM FROM POINTS;
   
    SET TOTALERROR = 0;
    OPEN C1;
    WHILE SQLSTATE = '00000' DO
      FETCH FROM C1 INTO XPT,YPT;
      SET TOTALERROR = TOTALERROR + (YPT - (SLOPE * XPT + YINT));
    END WHILE;
    CLOSE C1;
  END
  @
  