src-db/database/model/triggers/AD_COLUMN_TRG2.xml
changeset 1605 8a0fe0193bef
parent 1291 b56cf1635810
child 1929 ad0353d93b0f
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
    19 * Contributor(s):  ______________________________________.
    19 * Contributor(s):  ______________________________________.
    20 ************************************************************************/
    20 ************************************************************************/
    21   TYPE RECORD IS REF CURSOR;
    21   TYPE RECORD IS REF CURSOR;
    22   CUR_Clients RECORD;
    22   CUR_Clients RECORD;
    23   v_TableName VARCHAR2(40);
    23   v_TableName VARCHAR2(40);
    24   v_NextNo NUMBER;
    24   v_NextNo VARCHAR2(32);
    25   BEGIN
    25   BEGIN
    26   /**
    26   /**
    27   * Create Sequence for DocumentNo and Value columns
    27   * Create Sequence for DocumentNo and Value columns
    28   */
    28   */
    29   IF (:new.ColumnName = 'DocumentNo' OR :new.ColumnName = 'Value') THEN
    29   IF (:new.ColumnName = 'DocumentNo' OR :new.ColumnName = 'Value') THEN
    33          
    33          
    34     FOR CUR_Clients IN (
    34     FOR CUR_Clients IN (
    35       SELECT ad_client_id
    35       SELECT ad_client_id
    36       FROM ad_client
    36       FROM ad_client
    37       WHERE NOT EXISTS (SELECT 1 FROM ad_sequence WHERE name = 'DocumentNo_' || v_tablename)
    37       WHERE NOT EXISTS (SELECT 1 FROM ad_sequence WHERE name = 'DocumentNo_' || v_tablename)
    38         AND ad_client_id <> 0
    38         AND ad_client_id <> '0'
    39     ) LOOP
    39     ) LOOP
    40       Ad_Sequence_Next('AD_Sequence', CUR_Clients.ad_client_id, v_NextNo) ;
    40       Ad_Sequence_Next('AD_Sequence', CUR_Clients.ad_client_id, v_NextNo) ;
    41       INSERT INTO AD_Sequence (
    41       INSERT INTO AD_Sequence (
    42         AD_Sequence_ID, AD_Client_ID, AD_Org_ID, IsActive, 
    42         AD_Sequence_ID, AD_Client_ID, AD_Org_ID, IsActive, 
    43         Created, CreatedBy, Updated, UpdatedBy,
    43         Created, CreatedBy, Updated, UpdatedBy,
    44         Name, Description, 
    44         Name, Description, 
    45         VFormat, IsAutoSequence, IncrementNo, 
    45         VFormat, IsAutoSequence, IncrementNo, 
    46         StartNo, CurrentNext, CurrentNextSys, 
    46         StartNo, CurrentNext, CurrentNextSys, 
    47         IsTableID, Prefix, Suffix, StartNewYear
    47         IsTableID, Prefix, Suffix, StartNewYear
    48       ) VALUES (
    48       ) VALUES (
    49         v_NextNo, CUR_Clients.ad_client_id, 0, 'Y',
    49         v_NextNo, CUR_Clients.ad_client_id, '0', 'Y',
    50         now(), 0, now(), 0,
    50         now(), '0', now(), '0',
    51         'DocumentNo_' || v_TableName,  'DocumentNo/Value for Table ' || v_TableName,
    51         'DocumentNo_' || v_TableName,  'DocumentNo/Value for Table ' || v_TableName,
    52         NULL,  'Y', 1,
    52         NULL,  'Y', 1,
    53         10000000, 10000000, 10000000,
    53         10000000, 10000000, 10000000,
    54         'N', NULL, NULL, 'N'
    54         'N', NULL, NULL, 'N'
    55       );
    55       );