Files
DSpace/dspace/etc/oracle/updateseq.sql
Graham Triggs 6c40b8a3b2 Fix Oracle sequence resetting
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2248 9c30dcfa-912a-0410-8fc2-9e0234be79fd
2007-10-05 16:01:40 +00:00

31 lines
749 B
SQL
Executable File

-- #############################################################################################
--
-- %Purpose: Set a sequence to the max value of a given attribute
--
-- #############################################################################################
--
-- Paramters:
-- 1: sequence name
-- 2: table name
-- 3: attribute name
--
-- Sample usage:
-- @updateseq.sql my_sequence my_table my_attribute
--
--------------------------------------------------------------------------------
--
SET SERVEROUTPUT ON SIZE 1000000;
--
DECLARE
curr NUMBER := 0;
BEGIN
SELECT max(&3) INTO curr FROM &2 ;
curr := curr + 1;
EXECUTE IMMEDIATE 'DROP SEQUENCE &1';
EXECUTE IMMEDIATE 'CREATE SEQUENCE &1 START WITH ' || curr;
END;
/