diff --git a/db/ddlutils/oracle/functions/NextIDByYear.sql b/db/ddlutils/oracle/functions/NextIDByYear.sql new file mode 100644 index 0000000000..bdffb90681 --- /dev/null +++ b/db/ddlutils/oracle/functions/NextIDByYear.sql @@ -0,0 +1,24 @@ +CREATE or REPLACE PROCEDURE NextIDByYear +( + p_AD_Sequence_ID IN NUMBER, + p_IncrementNo IN NUMBER, + p_CalendarYear IN CHAR, + o_NextID OUT NUMBER +) +AS +BEGIN + SELECT CurrentNext + INTO o_NextID + FROM AD_Sequence_No + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear + FOR UPDATE OF CurrentNext; + -- + UPDATE AD_Sequence_No + SET CurrentNext = CurrentNext + p_IncrementNo + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear; +EXCEPTION + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE(SQLERRM); +END NextIDByYear; diff --git a/db/ddlutils/postgresql/functions/NextIDByYear.sql b/db/ddlutils/postgresql/functions/NextIDByYear.sql new file mode 100644 index 0000000000..1fdc19e2fd --- /dev/null +++ b/db/ddlutils/postgresql/functions/NextIDByYear.sql @@ -0,0 +1,24 @@ +CREATE or REPLACE FUNCTION NextIDByYear +( + p_AD_Sequence_ID IN numeric, + p_IncrementNo IN numeric, + p_CalendarYear IN varchar +) +RETURNS numeric AS $$ +DECLARE + o_NextID numeric; +BEGIN + SELECT CurrentNext + INTO o_NextID + FROM ad_sequence_no + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear + FOR UPDATE OF ad_sequence_no; + -- + UPDATE ad_sequence_no + SET CurrentNext = CurrentNext + p_IncrementNo + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear; + RETURN o_NextID; +END +$$ LANGUAGE plpgsql; diff --git a/migration/353a-trunk/oracle/379_FR1883270_NextIdByYear.sql b/migration/353a-trunk/oracle/379_FR1883270_NextIdByYear.sql new file mode 100644 index 0000000000..9d8fb55ee4 --- /dev/null +++ b/migration/353a-trunk/oracle/379_FR1883270_NextIdByYear.sql @@ -0,0 +1,29 @@ +CREATE or REPLACE PROCEDURE NextIDByYear +( + p_AD_Sequence_ID IN NUMBER, + p_IncrementNo IN NUMBER, + p_CalendarYear IN CHAR, + o_NextID OUT NUMBER +) +AS +BEGIN + SELECT CurrentNext + INTO o_NextID + FROM AD_Sequence_No + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear + FOR UPDATE OF CurrentNext; + -- + UPDATE AD_Sequence_No + SET CurrentNext = CurrentNext + p_IncrementNo + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear; +EXCEPTION + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE(SQLERRM); +END NextIDByYear; +/ + +-- [ 1883270 ] Enhance Document No Formatting +UPDATE AD_Field SET IsActive='Y' WHERE AD_Field_ID=335 +; diff --git a/migration/353a-trunk/postgresql/379_FR1883270_NextIdByYear.sql b/migration/353a-trunk/postgresql/379_FR1883270_NextIdByYear.sql new file mode 100644 index 0000000000..827764fead --- /dev/null +++ b/migration/353a-trunk/postgresql/379_FR1883270_NextIdByYear.sql @@ -0,0 +1,28 @@ +CREATE or REPLACE FUNCTION NextIDByYear +( + p_AD_Sequence_ID IN numeric, + p_IncrementNo IN numeric, + p_CalendarYear IN varchar +) +RETURNS numeric AS $$ +DECLARE + o_NextID numeric; +BEGIN + SELECT CurrentNext + INTO o_NextID + FROM ad_sequence_no + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear + FOR UPDATE OF ad_sequence_no; + -- + UPDATE ad_sequence_no + SET CurrentNext = CurrentNext + p_IncrementNo + WHERE AD_Sequence_ID=p_AD_Sequence_ID + AND CalendarYear = p_CalendarYear; + RETURN o_NextID; +END +$$ LANGUAGE plpgsql; + +-- [ 1883270 ] Enhance Document No Formatting +UPDATE AD_Field SET IsActive='Y' WHERE AD_Field_ID=335 +;