details: https://code.openbravo.com/erp/devel/pi/rev/779e903eb715 changeset: 18209:779e903eb715 user: Miguel A. Alsasua <miguel.alsasua <at> openbravo.com> date: Mon Oct 15 10:26:43 2012 +0200 summary: added new functions to manage trees
diffstat: src-db/database/model/functions/AD_GET_LEVEL_NODE_TREE.xml | 53 +++++++++++ src-db/database/model/functions/AD_GET_NODE_TREE_BYLEVEL.xml | 55 ++++++++++++ 2 files changed, 108 insertions(+), 0 deletions(-) diffs (116 lines): diff -r 95f0f9c3a7cd -r 779e903eb715 src-db/database/model/functions/AD_GET_LEVEL_NODE_TREE.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-db/database/model/functions/AD_GET_LEVEL_NODE_TREE.xml Mon Oct 15 10:26:43 2012 +0200 @@ -0,0 +1,53 @@ +<?xml version="1.0"?> + <database name="FUNCTION AD_GET_LEVEL_NODE_TREE"> + <function name="AD_GET_LEVEL_NODE_TREE" type="NUMERIC"> + <parameter name="p_tree_id" type="VARCHAR" mode="in"> + <default/> + </parameter> + <parameter name="p_node_id" type="VARCHAR" mode="in"> + <default/> + </parameter> + <body><![CDATA[/************************************************************************* +* The contents of this file are subject to the Openbravo Public License +* Version 1.1 (the "License"), being the Mozilla Public License +* Version 1.1 with a permitted attribution clause; you may not use this +* file except in compliance with the License. You may obtain a copy of +* the License at http://www.openbravo.com/legal/license.html +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +* License for the specific language governing rights and limitations +* under the License. +* The Original Code is Openbravo ERP. +* The Initial Developer of the Original Code is Openbravo SLU +* All portions are Copyright (C) 2001-2008 Openbravo SLU +* All Rights Reserved. +* Contributor(s): ______________________________________. +************************************************************************/ + p NUMBER(3); + vp VARCHAR2(32); + vExists NUMBER; +BEGIN + + SELECT COUNT(1) INTO vExists + FROM ad_treenode + WHERE node_id = p_node_id + AND ad_tree_id = p_tree_id; + + IF (vExists = 0) THEN RETURN -1; + ELSE + SELECT parent_id + INTO vp + FROM ad_treenode + WHERE node_id = p_node_id + AND ad_tree_id = p_tree_id; + + IF (vp= '0') then return 0; end if; + + p := AD_GET_LEVEL_NODE_TREE(p_tree_id, vp); + RETURN p+1; + END IF; + EXCEPTION WHEN OTHERS THEN RETURN 0; +END AD_GET_LEVEL_NODE_TREE +]]></body> + </function> + </database> diff -r 95f0f9c3a7cd -r 779e903eb715 src-db/database/model/functions/AD_GET_NODE_TREE_BYLEVEL.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-db/database/model/functions/AD_GET_NODE_TREE_BYLEVEL.xml Mon Oct 15 10:26:43 2012 +0200 @@ -0,0 +1,55 @@ +<?xml version="1.0"?> + <database name="FUNCTION AD_GET_NODE_TREE_BYLEVEL"> + <function name="AD_GET_NODE_TREE_BYLEVEL" type="VARCHAR"> + <parameter name="p_tree_id" type="VARCHAR" mode="in"> + <default/> + </parameter> + <parameter name="p_node_id" type="VARCHAR" mode="in"> + <default/> + </parameter> + <parameter name="p_level" type="NUMERIC" mode="in"> + <default/> + </parameter> + <body><![CDATA[/************************************************************************* +* The contents of this file are subject to the Openbravo Public License +* Version 1.1 (the "License"), being the Mozilla Public License +* Version 1.1 with a permitted attribution clause; you may not use this +* file except in compliance with the License. You may obtain a copy of +* the License at http://www.openbravo.com/legal/license.html +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +* License for the specific language governing rights and limitations +* under the License. +* The Original Code is Openbravo ERP. +* The Initial Developer of the Original Code is Openbravo SLU +* All portions are Copyright (C) 2001-2008 Openbravo SLU +* All Rights Reserved. +* Contributor(s): ______________________________________. +************************************************************************/ +p NUMBER(3); + vp VARCHAR2(32); + vExists NUMBER; +BEGIN + + SELECT COUNT(1) INTO vExists + FROM ad_treenode + WHERE node_id = p_node_id + AND ad_tree_id = p_tree_id; + + IF (vExists = 0) THEN RETURN NULL; + ELSE + SELECT parent_id + INTO vp + FROM ad_treenode + WHERE node_id = p_node_id + AND ad_tree_id = p_tree_id; + + + IF(AD_GET_LEVEL_NODE_TREE(p_tree_id, p_node_id)<=p_level) then return p_node_id; end if; + RETURN AD_GET_NODE_TREE_BYLEVEL(p_tree_id, vp, p_level); + END IF; + EXCEPTION WHEN OTHERS THEN RETURN p_node_id; +END AD_GET_NODE_TREE_BYLEVEL +]]></body> + </function> + </database> ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
