No need to do pl/sql, this can be achieved using the pseudo column LEVEL
and the CONNECT BY
clause in pure SQL. Very useful for selects like date lists, number lists, etc. For a list of numbers from 1 to 20 you could do this:
SELECT
level AS display_value,
level AS return_value
FROM
dual
CONNECT BY
level <= 20
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…