modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/CreateDocumentNoSequence_Data.xsql
changeset 9076 c4f1a5c7d7c2
child 10772 802557f42def
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0" encoding="UTF-8" ?>
       
     2 <!--
       
     3  ************************************************************************************
       
     4  * Copyright (C) 2010 Openbravo S.L.U.
       
     5  * Licensed under the Openbravo Commercial License version 1.0
       
     6  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
       
     7  * or in the legal folder of this module distribution.
       
     8  ************************************************************************************
       
     9 -->
       
    10 <SqlClass name="CreateDocumentNoSequenceData" package="org.openbravo.advpaymentmngt.modulescript">
       
    11    <SqlClassComment></SqlClassComment>
       
    12    <SqlMethod name="select" type="preparedStatement" return="multiple">
       
    13     <SqlMethodComment></SqlMethodComment>
       
    14     <Sql>
       
    15       <![CDATA[
       
    16       SELECT tablename, ad_client.ad_client_id as client
       
    17       FROM ad_table, ad_client
       
    18       WHERE EXISTS (SELECT 1 FROM ad_column
       
    19                     WHERE ad_column.ad_table_id = ad_table.ad_table_id
       
    20                       AND columnname IN ('DocumentNo', 'Value'))
       
    21       AND NOT EXISTS (SELECT 1 FROM ad_sequence
       
    22                       WHERE name LIKE 'DocumentNo_' || ad_table.tablename
       
    23                         AND ad_sequence.ad_client_id = ad_client.ad_client_id)
       
    24       AND ad_client.ad_client_id  <> '0'
       
    25       ]]>
       
    26     </Sql>
       
    27   </SqlMethod>
       
    28 <SqlMethod name="insertDocumentNoSequence" type="preparedStatement" connection="true" return="rowCount">
       
    29     <SqlMethodComment></SqlMethodComment>
       
    30     <Sql>
       
    31       <![CDATA[
       
    32       INSERT INTO AD_Sequence (
       
    33         AD_Sequence_ID, AD_Client_ID, AD_Org_ID, IsActive, 
       
    34         Created, CreatedBy, Updated, UpdatedBy,
       
    35         Name, Description, 
       
    36         VFormat, IsAutoSequence, IncrementNo, 
       
    37         StartNo, CurrentNext, CurrentNextSys, 
       
    38         IsTableID, Prefix, Suffix, StartNewYear
       
    39       ) VALUES (
       
    40         get_uuid(), ?, '0', 'Y',
       
    41         now(), '0', now(), '0',
       
    42         'DocumentNo_' || ?,  'DocumentNo/Value for Table ' || ?,
       
    43         NULL,  'Y', 1,
       
    44         10000000, 10000000, 10000000,
       
    45         'N', NULL, NULL, 'N'
       
    46       )
       
    47       ]]>
       
    48     </Sql>
       
    49     <Parameter name="clientId"/>
       
    50     <Parameter name="tablename"/>
       
    51     <Parameter name="tablename"/>
       
    52   </SqlMethod>
       
    53 </SqlClass>