DROP TABLE tbl;
CREATE TABLE tbl
(
        u       NUMBER,
        v       NUMBER
);

INSERT INTO tbl ( u, v ) VALUES ( 20, 50 );
INSERT INTO tbl ( u, v ) VALUES ( 21, 50 );
INSERT INTO tbl ( u, v ) VALUES ( 21, 51 );
INSERT INTO tbl ( u, v ) VALUES ( 22, 50 );
INSERT INTO tbl ( u, v ) VALUES ( 22, 55 );

commit;

WITH
        FUNCTION gcd ( ui IN NUMBER, vi IN NUMBER )
        RETURN NUMBER
        IS
                u NUMBER:= ui;
                v NUMBER:= vi;
                t NUMBER;
        BEGIN
                while v > 0
                loop
                        t:= u;
                        u:= v;
                        v:= MOD(t, v );
                END loop;
                RETURN abs(u);
        END gcd;
        SELECT u, v, gcd ( u, v )
        FROM tbl
/