[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4702] addons/1.3/colombia_general/trunk/sql/modules



Revision: 4702
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4702&view=rev
Author:   einhverfr
Date:     2012-05-08 10:53:06 +0000 (Tue, 08 May 2012)
Log Message:
-----------
Correcting some oversights in what was committed to Colombian modules

Modified Paths:
--------------
    addons/1.3/colombia_general/trunk/sql/modules/colombia-tables.sql

Added Paths:
-----------
    addons/1.3/colombia_general/trunk/sql/modules/colombia-general.sql

Added: addons/1.3/colombia_general/trunk/sql/modules/colombia-general.sql
===================================================================
--- addons/1.3/colombia_general/trunk/sql/modules/colombia-general.sql	                        (rev 0)
+++ addons/1.3/colombia_general/trunk/sql/modules/colombia-general.sql	2012-05-08 10:53:06 UTC (rev 4702)
@@ -0,0 +1,24 @@
+BEGIN;
+
+CREATE FUNCTION entity__get_provinces()
+RETURNS LISTOF province AS
+$$ select * from province order by code;$$ language sql;
+
+CREATE FUNCTION entity__get_municipalities () RETURNS LISTOF municipality AS
+$$ select * from municipality order by code; $$ language sql;
+
+CREATE FUNCTION entity__set_muni_province 
+(in_id int, in_province_id int, in_municipality_id int)
+RETURNS BOOL AS
+$$
+BEGIN;
+
+UPDATE entity SET province_id = $2, municipality_id = $3 WHERE id = $1;
+
+RETURN FOUND;
+
+END;
+$$ LANGUAGE PLPGSQL;
+
+
+COMMIT;

Modified: addons/1.3/colombia_general/trunk/sql/modules/colombia-tables.sql
===================================================================
--- addons/1.3/colombia_general/trunk/sql/modules/colombia-tables.sql	2012-05-07 03:00:07 UTC (rev 4701)
+++ addons/1.3/colombia_general/trunk/sql/modules/colombia-tables.sql	2012-05-08 10:53:06 UTC (rev 4702)
@@ -1,13 +1,17 @@
 CREATE TABLE municipality (
    id serial not null unique,
    code text primary key,
-   name text not nul unique
+   name text not null
 );
 CREATE TABLE province (
    id serial not null unique,
    code text primary key,
-   name text not nul unique
+   name text not null unique
 );
+
+\copy municipality (code, name) from 'sql/csv/city.csv' with CSV;
+\copy province (code, name) from 'sql/csv/province.csv' with CSV;
+
 ALTER TABLE country ADD code text unique;
 ALTER TABLE entity ADD province_id int references province (id);
 ALTER TABLE entity ADD municipality_id int references municipality (id);

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.