src-db/database/model/functions/AD_SEQUENCE_DOCTYPE.xml
changeset 1605 8a0fe0193bef
parent 785 8dba91261590
child 4473 c7b88381dc8b
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2   <database name="FUNCTION AD_SEQUENCE_DOCTYPE">
     2   <database name="FUNCTION AD_SEQUENCE_DOCTYPE">
     3     <function name="AD_SEQUENCE_DOCTYPE" type="NULL">
     3     <function name="AD_SEQUENCE_DOCTYPE" type="NULL">
     4       <parameter name="p_doctype_id" type="NUMERIC" mode="in">
     4       <parameter name="p_doctype_id" type="VARCHAR" mode="in">
     5         <default/>
     5         <default/>
     6       </parameter>
     6       </parameter>
     7       <parameter name="p_id" type="NUMERIC" mode="in">
     7       <parameter name="p_id" type="VARCHAR" mode="in">
     8         <default/>
     8         <default/>
     9       </parameter>
     9       </parameter>
    10       <parameter name="p_update_next" type="CHAR" mode="in">
    10       <parameter name="p_update_next" type="CHAR" mode="in">
    11         <default/>
    11         <default/>
    12       </parameter>
    12       </parameter>
    40   *  store in parameter p_DocumentNo
    40   *  store in parameter p_DocumentNo
    41   *  If ID < 1000000, use System Doc Sequence
    41   *  If ID < 1000000, use System Doc Sequence
    42   *  If no Document Sequence is defined, return null !
    42   *  If no Document Sequence is defined, return null !
    43   *   Use AD_Sequence_Doc('DocumentNo_myTable',.. to get it directly
    43   *   Use AD_Sequence_Doc('DocumentNo_myTable',.. to get it directly
    44   ************************************************************************/
    44   ************************************************************************/
    45   v_NextNo NUMBER;
    45   v_NextNo VARCHAR2(32);
    46   v_NextNoSys NUMBER;
    46   v_NextNoSys NUMBER;
    47   v_Sequence_ID NUMBER:=NULL;
    47   v_Sequence_ID VARCHAR2(32):=NULL;
    48   v_Prefix VARCHAR2(30) ;
    48   v_Prefix VARCHAR2(30) ;
    49   v_Suffix VARCHAR2(30) ;
    49   v_Suffix VARCHAR2(30) ;
    50 BEGIN
    50 BEGIN
    51   -- Is a document Sequence defined and valid
    51   -- Is a document Sequence defined and valid
    52 BEGIN
    52 BEGIN
    68 SELECT s.AD_Sequence_ID, s.CurrentNext, s.CurrentNextSys, s.Prefix, s.Suffix
    68 SELECT s.AD_Sequence_ID, s.CurrentNext, s.CurrentNextSys, s.Prefix, s.Suffix
    69 INTO v_Sequence_ID, v_NextNo, v_NextNoSys, v_Prefix, v_Suffix
    69 INTO v_Sequence_ID, v_NextNo, v_NextNoSys, v_Prefix, v_Suffix
    70 FROM C_DocType d, AD_Sequence s
    70 FROM C_DocType d, AD_Sequence s
    71 WHERE d.C_DocType_ID=p_DocType_ID -- parameter
    71 WHERE d.C_DocType_ID=p_DocType_ID -- parameter
    72   AND d.DocNoSequence_ID=s.AD_Sequence_ID  AND s.IsActive='Y'  AND s.IsTableID='N'  AND s.IsAutoSequence='Y'  FOR UPDATE OF CurrentNext, CurrentNextSys;
    72   AND d.DocNoSequence_ID=s.AD_Sequence_ID  AND s.IsActive='Y'  AND s.IsTableID='N'  AND s.IsAutoSequence='Y'  FOR UPDATE OF CurrentNext, CurrentNextSys;
    73 IF(v_NextNoSys<>-1 AND p_ID<1000000) THEN -- System No
    73 IF(v_NextNoSys<>-1 AND p_ID<'1000000') THEN -- System No
    74   IF p_Update_Next='Y' THEN
    74   IF p_Update_Next='Y' THEN
    75     UPDATE AD_Sequence
    75     UPDATE AD_Sequence
    76       SET CurrentNextSys=CurrentNextSys + IncrementNo
    76       SET CurrentNextSys=CurrentNextSys + IncrementNo
    77     WHERE AD_Sequence_ID=v_Sequence_ID;
    77     WHERE AD_Sequence_ID=v_Sequence_ID;
    78   END IF;
    78   END IF;