I need to produce a stored procedure in Ingres capable of taking a list of IDs and producing a new set of IDs which are unrelated to the first set (but where we store each pair).
My initial plan was to sort by random(), and use a sequence to simply number each row from 100000, then save these results into a table. This mostly works. However, because ALTER SEQUENCE cannot be used inside a stored procedure I have no way of ensuring that the new ids always start from 100000.
CREATE PROCEDURE create_external_dataset (datasetid varchar(12) NOT NULL) AS
BEGIN
INSERT INTO external_sids
SELECT :datasetid, NEXT VALUE FOR random_order_rank, sid
FROM id_table
ORDER BY random()
FETCH FIRST 300000 ROWS ONLY;
END;
ALTER SEQUENCE random_order_rank RESTART WITH 100000;
EXECUTE PROCEDURE create_external_dataset('LTF-5463');
Is there any way of resetting a sequence from within a stored procedure or creating a stored procedure only instance of a sequence?
Failing that, is there a way of producing incremental numbers in Ingres which does not use sequences?