* split model by table

* split seed data by table
* sync with 3.1.3 changes
* restore the use of nvarchar2 for compatibility with existing schema
This commit is contained in:
Heng Sin Low 2006-12-28 09:25:15 +00:00
parent d34a819c32
commit bf0dc74d3f
6 changed files with 375 additions and 79 deletions

View File

@ -45,8 +45,8 @@
<target name="writeSchemaToDb"> <target name="writeSchemaToDb">
<ddlToDatabase validatexml="false" usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}"> <ddlToDatabase validatexml="false" usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}">
<database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" /> <database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" />
<fileset dir=".."> <fileset dir="../model">
<include name="${schemafiles}" /> <include name="**/*.xml" />
</fileset> </fileset>
<writeschematodatabase alterdatabase="${alterdatabase}" dodrops="false" failonerror="false" /> <writeschematodatabase alterdatabase="${alterdatabase}" dodrops="false" failonerror="false" />
@ -56,8 +56,8 @@
<target name="writeSchemaSqlToFile"> <target name="writeSchemaSqlToFile">
<ddlToDatabase validatexml="false" usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}"> <ddlToDatabase validatexml="false" usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}">
<database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" /> <database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" />
<fileset dir=".."> <fileset dir="../model">
<include name="${schemafiles}" /> <include name="**/*.xml" />
</fileset> </fileset>
<writeschemasqltofile alterdatabase="${alterdatabase}" dodrops="false" failonerror="false" createtables="true" createforeignkeys="false" outputfile="${sqloutputfile}" /> <writeschemasqltofile alterdatabase="${alterdatabase}" dodrops="false" failonerror="false" createtables="true" createforeignkeys="false" outputfile="${sqloutputfile}" />
@ -67,8 +67,8 @@
<target name="writeFkSqlToFile"> <target name="writeFkSqlToFile">
<ddlToDatabase validatexml="false" usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}"> <ddlToDatabase validatexml="false" usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}">
<database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" /> <database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" />
<fileset dir=".."> <fileset dir="../model">
<include name="${schemafiles}" /> <include name="**/*.xml" />
</fileset> </fileset>
<writeschemasqltofile alterdatabase="${alterdatabase}" dodrops="false" failonerror="false" createtables="false" createforeignkeys="true" outputfile="${fkoutputfile}" /> <writeschemasqltofile alterdatabase="${alterdatabase}" dodrops="false" failonerror="false" createtables="false" createforeignkeys="true" outputfile="${fkoutputfile}" />
@ -91,13 +91,39 @@
<target name="writeDataToDb"> <target name="writeDataToDb">
<ddlToDatabase usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}">
<database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" />
<fileset dir="../model">
<include name="**/*.xml" />
</fileset>
<writedatatodatabase usebatchmode="false" ensureForeignKeyOrder="false" >
<fileset dir="../data">
<include name="**/*.xml" />
</fileset>
</writedatatodatabase>
</ddlToDatabase>
</target>
<target name="splitSchemaFileByTable">
<ddlToDatabase usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}"> <ddlToDatabase usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}">
<database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" /> <database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" />
<fileset dir=".."> <fileset dir="..">
<include name="${schemafiles}" /> <include name="${schemafiles}" />
</fileset> </fileset>
<writedatatodatabase datafile="${datafile}" usebatchmode="false" ensureForeignKeyOrder="false" /> <splitSchemaFileByTable destination="../model"/>
</ddlToDatabase>
</target>
<target name="splitDataFileByTable">
<ddlToDatabase usedelimitedsqlidentifiers="${delimitedsqlidentifiers}" catalogpattern="${catalogpattern}" schemapattern="${schemapattern}" databasetype="${platform}">
<database driverclassname="${datasource.driverClassName}" url="${datasource.url}" username="${datasource.username}" password="${datasource.password}" />
<fileset dir="../model">
<include name="**/*.xml" />
</fileset>
<splitDataFileByTable destination="../data" datafile="${datafile}"/>
</ddlToDatabase> </ddlToDatabase>
</target> </target>
</project> </project>

View File

@ -33,23 +33,18 @@
</target> </target>
<target name="load-data"> <target name="load-data">
<echo message="----- Loading Adempiere Seed data -----" /> <echo message="----- Loading Adempiere Seed data -----" />
<unjar src="../adempiere-data.jar" dest=".." />
<ant antfile="build-ddl.xml" target="writeDataToDb" /> <ant antfile="build-ddl.xml" target="writeDataToDb" />
<delete file="../adempiere-data.xml" />
</target> </target>
<target name="load-functions"> <target name="load-functions">
<echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Functions:${line.separator}${line.separator}" /> <echo file="log/sqlplus.log" append="true" message="${line.separator}#Initialise DB:${line.separator}${line.separator}" />
<antcall target="load"> <antcall target="load">
<param name="file.name" value="${basedir}/init.sql" /> <param name="file.name" value="${basedir}/init.sql" />
</antcall> </antcall>
<foreach param="file.name" target="load"> <antcall target="load">
<path> <param name="file.name" value="${basedir}/functions-decl.sql" />
<fileset dir="functions"> </antcall>
<include name="**" />
</fileset>
</path>
</foreach>
<echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Procedures:${line.separator}${line.separator}" /> <echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Procedures:${line.separator}${line.separator}" />
<foreach param="file.name" target="load"> <foreach param="file.name" target="load">
<path> <path>
@ -62,11 +57,6 @@
<target name="load-others"> <target name="load-others">
<echo message="----- Loading other database objects -----" /> <echo message="----- Loading other database objects -----" />
<echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Temporary Tables:${line.separator}${line.separator}" />
<antcall target="load">
<param name="file.name" value="${basedir}/temptables.sql" />
</antcall>
<echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Views [1st Pass]:${line.separator}${line.separator}" /> <echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Views [1st Pass]:${line.separator}${line.separator}" />
<foreach param="file.name" target="load"> <foreach param="file.name" target="load">
<path> <path>
@ -85,6 +75,15 @@
</path> </path>
</foreach> </foreach>
<echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Functions:${line.separator}${line.separator}" />
<foreach param="file.name" target="load">
<path>
<fileset dir="functions">
<include name="**" />
</fileset>
</path>
</foreach>
<echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Sequences:${line.separator}${line.separator}" /> <echo file="log/sqlplus.log" append="true" message="${line.separator}#Create Sequences:${line.separator}${line.separator}" />
<foreach param="file.name" target="load"> <foreach param="file.name" target="load">
<path> <path>

View File

@ -0,0 +1,283 @@
CREATE OR REPLACE FUNCTION acctBalance
(
p_Account_ID IN NUMBER,
p_AmtDr IN NUMBER,
p_AmtCr IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETUNR 0;
END;
/
CREATE OR REPLACE FUNCTION bomPriceLimit
(
Product_ID IN NUMBER,
PriceList_Version_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bomPriceList
(
Product_ID IN NUMBER,
PriceList_Version_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bomPriceStd
(
Product_ID IN NUMBER,
PriceList_Version_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bomQtyAvailable
(
Product_ID IN NUMBER,
Warehouse_ID IN NUMBER,
Locator_ID IN NUMBER -- Only used, if warehouse is null
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bomQtyOnHand
(
Product_ID IN NUMBER,
Warehouse_ID IN NUMBER,
Locator_ID IN NUMBER -- Only used, if warehouse is null
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bomQtyOrdered
(
p_Product_ID IN NUMBER,
p_Warehouse_ID IN NUMBER,
p_Locator_ID IN NUMBER -- Only used, if warehouse is null
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bomQtyReserved
(
p_Product_ID IN NUMBER,
p_Warehouse_ID IN NUMBER,
p_Locator_ID IN NUMBER -- Only used, if warehouse is null
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION currencyBase
(
p_Amount IN NUMBER,
p_CurFrom_ID IN NUMBER,
p_ConvDate IN DATE,
p_Client_ID IN NUMBER,
p_Org_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION bpartnerRemitLocation
(
p_C_BPartner_ID C_BPartner.C_BPartner_ID%TYPE
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION currencyConvert
(
p_Amount IN NUMBER,
p_CurFrom_ID IN NUMBER,
p_CurTo_ID IN NUMBER,
p_ConvDate IN DATE,
p_ConversionType_ID IN NUMBER,
p_Client_ID IN NUMBER,
p_Org_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION currencyRate
(
p_CurFrom_ID IN NUMBER,
p_CurTo_ID IN NUMBER,
p_ConvDate IN DATE,
p_ConversionType_ID IN NUMBER,
p_Client_ID IN NUMBER,
p_Org_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION currencyRound
(
p_Amount IN NUMBER,
p_CurTo_ID IN NUMBER,
p_Costing IN VARCHAR2 -- Default 'N'
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION invoiceDiscount
(
p_C_Invoice_ID IN NUMBER,
p_PayDate IN DATE,
p_C_InvoicePaySchedule_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION invoiceOpen
(
p_C_Invoice_ID IN NUMBER,
p_C_InvoicePaySchedule_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION invoicePaid
(
p_C_Invoice_ID IN NUMBER,
p_C_Currency_ID IN NUMBER,
p_MultiplierAP IN NUMBER -- DEFAULT 1
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION paymentAllocated
(
p_C_Payment_ID IN NUMBER,
p_C_Currency_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION paymentAvailable
(
p_C_Payment_ID IN NUMBER
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION paymentTermDiscount
(
Amount IN NUMBER,
Currency_ID IN NUMBER,
PaymentTerm_ID IN NUMBER,
DocDate IN DATE,
PayDate IN DATE
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION paymentTermDueDate
(
PaymentTerm_ID IN NUMBER,
DocDate IN DATE
)
RETURN DATE AS
BEGIN
RETURN NULL;
END;
/
CREATE OR REPLACE FUNCTION paymentTermDueDays
(
PaymentTerm_ID IN NUMBER,
DocDate IN DATE,
PayDate IN DATE
)
RETURN NUMBER AS
BEGIN
RETURN 0;
END;
/
CREATE OR REPLACE FUNCTION DBA_ConstraintCmd
(
p_ConstraintName IN VARCHAR2
)
RETURN VARCHAR2 AS
BEGIN
RETURN NULL;
END;
/
CREATE OR REPLACE FUNCTION DBA_DisplayType
(
AD_Reference_ID IN NUMBER
)
RETURN VARCHAR2 AS
BEGIN
RETURN NULL;
END;
/
CREATE OR REPLACE FUNCTION productAttribute
(
p_M_AttributeSetInstance_ID IN NUMBER
)
RETURN VARCHAR2 AS
BEGIN
RETURN NULL;
END;
/

View File

@ -4,10 +4,10 @@ CREATE OR REPLACE PROCEDURE M_PriceList_Create
) )
AS AS
/************************************************************************* /*************************************************************************
* The contents of this file are subject to the Adempiere License. You may * The contents of this file are subject to the Compiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html * obtain a copy of the License at http://www.compiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM * express or implied. See the License for details. Code: Compiere ERP+CRM
* Copyright (C) 1999-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved. * Copyright (C) 1999-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved.
************************************************************************* *************************************************************************
* $Id: M_PriceList_Create.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ * $Id: M_PriceList_Create.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
@ -16,6 +16,7 @@ AS
* Description: * Description:
* Create PriceList by copying purchase prices (M_Product_PO) * Create PriceList by copying purchase prices (M_Product_PO)
* and applying product category discounts (M_CategoryDiscount) * and applying product category discounts (M_CategoryDiscount)
* Carlos Ruiz - globalqss - Make T_Selection tables permanent
************************************************************************/ ************************************************************************/
-- Logistice -- Logistice
ResultStr VARCHAR2(2000); ResultStr VARCHAR2(2000);
@ -173,15 +174,15 @@ BEGIN
-- DBMS_OUTPUT.PUT_LINE(ResultStr); -- DBMS_OUTPUT.PUT_LINE(ResultStr);
-- Clear Temporary Table -- Clear Temporary Table
DELETE FROM T_Selection; DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID;
-- ----------------------------------- -- -----------------------------------
-- Create Selection in temporary table -- Create Selection in temporary table
-- ----------------------------------- -- -----------------------------------
IF (v_PriceList_Version_Base_ID IS NULL) THEN IF (v_PriceList_Version_Base_ID IS NULL) THEN
-- Create Selection from M_Product_PO -- Create Selection from M_Product_PO
INSERT INTO T_Selection (T_Selection_ID) INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID)
SELECT DISTINCT po.M_Product_ID SELECT DISTINCT PInstance_ID, po.M_Product_ID
FROM M_Product p, M_Product_PO po FROM M_Product p, M_Product_PO po
WHERE p.M_Product_ID=po.M_Product_ID WHERE p.M_Product_ID=po.M_Product_ID
AND (p.AD_Client_ID=v_Client_ID OR p.AD_Client_ID=0) AND (p.AD_Client_ID=v_Client_ID OR p.AD_Client_ID=0)
@ -192,8 +193,8 @@ BEGIN
AND (dl.M_Product_ID IS NULL OR p.M_Product_ID=dl.M_Product_ID); AND (dl.M_Product_ID IS NULL OR p.M_Product_ID=dl.M_Product_ID);
ELSE ELSE
-- Create Selection from existing PriceList -- Create Selection from existing PriceList
INSERT INTO T_Selection (T_Selection_ID) INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID)
SELECT DISTINCT p.M_Product_ID SELECT DISTINCT PInstance_ID, p.M_Product_ID
FROM M_Product p, M_ProductPrice pp FROM M_Product p, M_ProductPrice pp
WHERE p.M_Product_ID=pp.M_Product_ID WHERE p.M_Product_ID=pp.M_Product_ID
AND pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID AND pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID
@ -213,7 +214,8 @@ BEGIN
ResultStr := ResultStr || ', Delete'; ResultStr := ResultStr || ', Delete';
DELETE M_ProductPrice pp DELETE M_ProductPrice pp
WHERE pp.M_PriceList_Version_ID = p_PriceList_Version_ID WHERE pp.M_PriceList_Version_ID = p_PriceList_Version_ID
AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID); AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID
AND s.AD_PInstance_ID = PInstance_ID);
Message := ', @Deleted@=' || SQL%ROWCOUNT; Message := ', @Deleted@=' || SQL%ROWCOUNT;
END IF; END IF;
@ -243,7 +245,8 @@ BEGIN
COALESCE(currencyConvert(po.PricePO, COALESCE(currencyConvert(po.PricePO,
po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0) po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0)
FROM M_Product_PO po FROM M_Product_PO po
WHERE EXISTS (SELECT * FROM T_Selection s WHERE po.M_Product_ID=s.T_Selection_ID) WHERE EXISTS (SELECT * FROM T_Selection s WHERE po.M_Product_ID=s.T_Selection_ID
AND s.AD_PInstance_ID = PInstance_ID)
AND po.IsCurrentVendor='Y' AND po.IsActive='Y'; AND po.IsCurrentVendor='Y' AND po.IsActive='Y';
ELSE ELSE
-- Copy and Convert from other PriceList_Version -- Copy and Convert from other PriceList_Version
@ -268,7 +271,8 @@ BEGIN
INNER JOIN M_PriceList_Version plv ON (pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID) INNER JOIN M_PriceList_Version plv ON (pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID)
INNER JOIN M_PriceList pl ON (plv.M_PriceList_ID=pl.M_PriceList_ID) INNER JOIN M_PriceList pl ON (plv.M_PriceList_ID=pl.M_PriceList_ID)
WHERE pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID WHERE pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID
AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID) AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID
AND s.AD_PInstance_ID = PInstance_ID)
AND pp.IsActive='Y'; AND pp.IsActive='Y';
END IF; END IF;
Message := Message || ', @Inserted@=' || SQL%ROWCOUNT; Message := Message || ', @Inserted@=' || SQL%ROWCOUNT;
@ -286,7 +290,8 @@ BEGIN
+ dl.Limit_AddAmt) * (1 - dl.Limit_Discount/100) + dl.Limit_AddAmt) * (1 - dl.Limit_Discount/100)
WHERE M_PriceList_Version_ID=p_PriceList_Version_ID WHERE M_PriceList_Version_ID=p_PriceList_Version_ID
AND EXISTS (SELECT * FROM T_Selection s AND EXISTS (SELECT * FROM T_Selection s
WHERE s.T_Selection_ID=p.M_Product_ID); WHERE s.T_Selection_ID=p.M_Product_ID
AND s.AD_PInstance_ID = PInstance_ID);
-- -------- -- --------
-- Rounding (AD_Reference_ID=155) -- Rounding (AD_Reference_ID=155)
@ -319,7 +324,8 @@ BEGIN
ROUND(PriceLimit, v_StdPrecision))-- Currency ROUND(PriceLimit, v_StdPrecision))-- Currency
WHERE M_PriceList_Version_ID=p_PriceList_Version_ID WHERE M_PriceList_Version_ID=p_PriceList_Version_ID
AND EXISTS (SELECT * FROM T_Selection s AND EXISTS (SELECT * FROM T_Selection s
WHERE s.T_Selection_ID=p.M_Product_ID); WHERE s.T_Selection_ID=p.M_Product_ID
AND s.AD_PInstance_ID = PInstance_ID);
Message := Message || ', @Updated@=' || SQL%ROWCOUNT; Message := Message || ', @Updated@=' || SQL%ROWCOUNT;
-- Fixed Price overwrite -- Fixed Price overwrite
@ -330,7 +336,8 @@ BEGIN
PriceLimit = DECODE(dl.Limit_Base, 'F', dl.Limit_Fixed, PriceLimit) PriceLimit = DECODE(dl.Limit_Base, 'F', dl.Limit_Fixed, PriceLimit)
WHERE M_PriceList_Version_ID=p_PriceList_Version_ID WHERE M_PriceList_Version_ID=p_PriceList_Version_ID
AND EXISTS (SELECT * FROM T_Selection s AND EXISTS (SELECT * FROM T_Selection s
WHERE s.T_Selection_ID=p.M_Product_ID); WHERE s.T_Selection_ID=p.M_Product_ID
AND s.AD_PInstance_ID = PInstance_ID);
-- Log Info -- Log Info
INSERT INTO AD_PInstance_Log (AD_PInstance_ID, Log_ID, P_ID, P_NUMBER, P_MSG) INSERT INTO AD_PInstance_Log (AD_PInstance_ID, Log_ID, P_ID, P_NUMBER, P_MSG)
@ -341,7 +348,7 @@ BEGIN
END LOOP; -- For all DiscountLines END LOOP; -- For all DiscountLines
-- Delete Temporary Selection -- Delete Temporary Selection
DELETE FROM T_Selection; DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID;
<<FINISH_PROCESS>> <<FINISH_PROCESS>>

View File

@ -3,10 +3,10 @@ CREATE OR REPLACE PROCEDURE M_Product_BOM_Check
PInstance_ID IN NUMBER PInstance_ID IN NUMBER
) )
/************************************************************************* /*************************************************************************
* The contents of this file are subject to the Adempiere License. You may * The contents of this file are subject to the Compiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html * obtain a copy of the License at http://www.compiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM * express or implied. See the License for details. Code: Compiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved. * Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
************************************************************************* *************************************************************************
* $Id: M_Product_BOM_Check.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ * $Id: M_Product_BOM_Check.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
@ -66,43 +66,44 @@ BEGIN
-- Checking BOM Structure -- Checking BOM Structure
ResultStr := 'InsertingRoot'; ResultStr := 'InsertingRoot';
-- Table to put all BOMs - duplicate will cause exception -- Table to put all BOMs - duplicate will cause exception
DELETE FROM T_Selection2 WHERE Query_ID = 0; DELETE FROM T_Selection2 WHERE Query_ID = 0 AND AD_PInstance_ID = PInstance_ID;
INSERT INTO T_Selection2 (Query_ID, T_Selection_ID) VALUES (0, Record_ID); INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) VALUES (PInstance_ID, 0, Record_ID);
-- Table of root modes -- Table of root modes
DELETE FROM T_Selection; DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID;
INSERT INTO T_Selection (T_Selection_ID) VALUES (Record_ID); INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) VALUES (PInstance_ID, Record_ID);
LOOP LOOP
-- How many do we have? -- How many do we have?
SELECT COUNT(*) SELECT COUNT(*)
INTO CountNo INTO CountNo
FROM T_Selection; FROM T_Selection
WHERE AD_PInstance_ID = PInstance_ID;
-- Nothing to do -- Nothing to do
EXIT WHEN (CountNo = 0); EXIT WHEN (CountNo = 0);
-- Insert BOM Nodes into "All" table -- Insert BOM Nodes into "All" table
INSERT INTO T_Selection2 (Query_ID, T_Selection_ID) INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID)
SELECT 0, p.M_Product_ID SELECT PInstance_ID, 0, p.M_Product_ID
FROM M_Product p FROM M_Product p
WHERE IsBOM='Y' WHERE IsBOM='Y'
AND EXISTS (SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND EXISTS (SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID
AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection)); AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID));
-- Insert BOM Nodes into temporary table -- Insert BOM Nodes into temporary table
DELETE FROM T_Selection2 WHERE Query_ID = 1; DELETE FROM T_Selection2 WHERE Query_ID = 1 AND AD_PInstance_ID = PInstance_ID;
INSERT INTO T_Selection2 (Query_ID, T_Selection_ID) INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID)
SELECT 1, p.M_Product_ID SELECT PInstance_ID, 1, p.M_Product_ID
FROM M_Product p FROM M_Product p
WHERE IsBOM='Y' WHERE IsBOM='Y'
AND EXISTS (SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND EXISTS (SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID
AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection)); AND b.M_Product_ID IN (SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID));
-- Copy into root table -- Copy into root table
DELETE FROM T_Selection; DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID;
INSERT INTO T_Selection (T_Selection_ID) INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID)
SELECT T_Selection_ID SELECT PInstance_ID, T_Selection_ID
FROM T_Selection2 FROM T_Selection2
WHERE Query_ID = 1; WHERE Query_ID = 1 AND AD_PInstance_ID = PInstance_ID;
END LOOP; END LOOP;

View File

@ -1,20 +0,0 @@
DROP TABLE T_Selection CASCADE CONSTRAINTS;
CREATE GLOBAL TEMPORARY TABLE T_Selection
(
T_Selection_ID NUMBER(10, 0) NOT NULL
CONSTRAINT T_Selection_Key PRIMARY KEY
)
ON COMMIT DELETE ROWS;
DROP TABLE T_Selection2;
CREATE GLOBAL TEMPORARY TABLE T_Selection2
(
Query_ID NUMBER NOT NULL,
T_Selection_ID NUMBER(10) NOT NULL,
CONSTRAINT T_Selection2_Key PRIMARY KEY (Query_ID,T_Selection_ID)
)
ON COMMIT PRESERVE ROWS;