On 5/30/07, Trigve Siver <[EMAIL PROTECTED]> wrote:
Can you point me to some sources
or give me some examples, please?

CREATE OR REPLACE FUNCTION ROWNUM() RETURNS BIGINT AS
$$
        BEGIN
                RETURN NEXTVAL('ROWNUM_SEQ');
        EXCEPTION WHEN OTHERS THEN
                CREATE TEMP SEQUENCE ROWNUM_SEQ;
                RETURN NEXTVAL('ROWNUM_SEQ');
        END;
$$
LANGUAGE 'PLPGSQL';

SELECT ROWNUM(), S.X
FROM GENERATE_SERIES(5,1,-1) S(X);

Remember to reset the sequence value if you use this more than once in
the same session.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

Reply via email to