Example 2: SQL statement with a result set

The following code executes a simple SELECT statement with the base.SqlHandle API:
MAIN
    DEFINE h base.SqlHandle,
           d DATE,
           i INTEGER

    CONNECT TO "mydb"

    LET h = base.SqlHandle.create()

    CALL h.prepare("SELECT * FROM t1 WHERE created > ?")

    LET d = TODAY
    CALL h.setParameter(1, d)

    CALL h.open()

    WHILE TRUE
        CALL h.fetch()
        IF SQLCA.SQLCODE==NOTFOUND THEN EXIT WHILE END IF
        DISPLAY "-----------------"
        FOR i=1 TO h.getResultCount()
            DISPLAY i, ":", h.getResultName(i),
                    " / ", h.getResultType(i),
                    " = ", h.getResultValue(i)
        END FOR
    END WHILE

    CALL h.close()

END MAIN