Hi again,
I have following problem:
CREATE SEQUENCE SEQ_TEST START WITH 1 INCREMENT BY 1 MAXVALUE 9999 CYCLE NOCACHE;
--
CREATE OR REPLACE FUNCTION Test RETURN NUMBER
AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Test');
RETURN SEQ_TEST.NEXTVAL;
END Test;
/
--
SELECT xyz, xyz
FROM (SELECT Test xyz FROM DUAL);
As a result I get always two consecutive values. So it means that the subquery is executed everytime I refer to it in the outer query. Why?
I would expect that the subquery would be executed only once and then I should get same values. Is there any optimizer hint to achieve this?
Thanks a lot in advance,
Dan