diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-01 01:37:57 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-01 01:37:57 +0000 |
commit | 9a27954c4c16bdee874490deabaf34b8eaff5edf (patch) | |
tree | e7fa023428d73a2a113023d059c930350f345203 /sql | |
parent | 182af25edbe0f0d3f2fab4ea61465e552004c242 (diff) |
Menu cross sections, used for example in handhelds, now work from an API point of view
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1477 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Pg-database.sql | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index 8d22a0cb..e0010afb 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -2543,6 +2543,35 @@ BEGIN END LOOP; END; $$ language plpgsql; + +CREATE OR REPLACE FUNCTION menu_children(in_parent_id int) RETURNS SETOF menu_item +AS $$ +declare + item menu_item; + arg menu_attribute%ROWTYPE; +begin + FOR item IN + SELECT n.position, n.id, c.level, n.label, c.path, '{}' + FROM connectby('menu_node', 'id', 'parent', 'position', + in_parent_id, 1, ',') + c(id integer, parent integer, "level" integer, + path text, list_order integer) + JOIN menu_node n USING(id) + LOOP + FOR arg IN + SELECT * + FROM menu_attribute + WHERE node_id = item.id + LOOP + item.args := item.args || + (arg.attribute || '=' || arg.value)::varchar; + END LOOP; + return next item; + end loop; +end; +$$ language plpgsql; + +COMMENT ON FUNCTION menu_children(int) IS $$ This function returns all menu items which are children of in_parent_id (the only input parameter. $$; -- -- PostgreSQL database dump -- |