mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00

git-svn-id: http://scm.dspace.org/svn/repo/trunk@2248 9c30dcfa-912a-0410-8fc2-9e0234be79fd
31 lines
749 B
SQL
Executable File
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;
|
|
/
|