August 4th, 2003, 01:46 AM
I have to do select statement but I wish to add another column which print out sequence number for each row.
August 4th, 2003, 10:31 AM
Just create a temporary sequence, and drop it when you are done. (or, you can just leave it, and expect it to be dropped automatically when you finish the current database session).
Since temporary sequences (like temporary tables) are private to the session user, it doesn't matter if the same piece of code is being run by many different users, because they will each be only accessing their own 'tempcounter' sequence.
CREATE TEMPORARY SEQUENCE tempcounter START 1;
SELECT nextval('tempcounter') as counter, mycolumn FROM mytable;
DROP sequence tempcounter;