[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Noticed that admin_middlename does not save with my script
- Subject: Noticed that admin_middlename does not save with my script
- From: Chris Bennett <..hidden..>
- Date: Thu, 29 Mar 2012 10:02:29 -0500
The procedure person__save skips middle names.
Would this be an appropriate diff?
--- /var/www/var/www/htdocs/users/ledgersmb/sql/modules/Person.sql Fri Nov 25 22:27:16 2011
+++ Person.sql Thu Mar 29 05:54:59 2012
@@ -47,12 +47,12 @@
IF FOUND THEN
UPDATE entity
- SET name = in_first_name || ' ' || in_last_name,
+ SET name = in_first_name || ' ' || in_middle_name || ' ' || in_last_name,
country_id = in_country_id
WHERE id = in_entity_id;
ELSE
INSERT INTO entity (name, entity_class, country_id)
- values (in_first_name || ' ' || in_last_name, 3, in_country_id);
+ values (in_first_name || ' ' || in_middle_name || ' ' || in_last_name, 3, in_country_id);
e_id := currval('entity_id_seq');
END IF;
@@ -70,8 +70,8 @@
ELSE
-- Do an insert
- INSERT INTO person (salutation_id, first_name, last_name, entity_id)
- VALUES (in_salutation_id, in_first_name, in_last_name, e_id);
+ INSERT INTO person (salutation_id, first_name, middle_name, last_name, entity_id)
+ VALUES (in_salutation_id, in_first_name, in_middle_name, in_last_name, e_id);
RETURN e_id;
@@ -86,6 +86,29 @@
) IS
$$ Saves the person with the information specified. Returns the entity_id
of the record saved.$$;
+
+
+CREATE OR REPLACE FUNCTION person__list_locations(in_entity_id int)
+RETURNS SETOF location_result AS
+$$
+DECLARE out_row RECORD;
+BEGIN
+ FOR out_row IN
+ SELECT l.id, l.line_one, l.line_two, l.line_three, l.city,
+ l.state, l.mail_code, c.id, c.name, lc.id, lc.class
+ FROM location l
+ JOIN person_to_location ctl ON (ctl.location_id = l.id)
+ JOIN person p ON (ctl.person_id = p.id)
+ JOIN location_class lc ON (ctl.location_class = lc.id)
+ JOIN country c ON (c.id = l.country_id)
+ WHERE p.entity_id = in_entity_id
+ ORDER BY lc.id, l.id, c.name
+ LOOP
+ RETURN NEXT out_row;
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
CREATE OR REPLACE FUNCTION person__list_locations(in_entity_id int)
RETURNS SETOF location_result AS
I also noticed that middle name is not always used on screen.
Is this deliberate?
Another question.
Here in Texas, many people, and in Latin countries, everyone has two last names which are considered approproate to use. Should a second last name field be added?
Chris Bennett
--- /var/www/var/www/htdocs/users/ledgersmb/sql/modules/Person.sql Fri Nov 25 22:27:16 2011
+++ Person.sql Thu Mar 29 05:54:59 2012
@@ -47,12 +47,12 @@
IF FOUND THEN
UPDATE entity
- SET name = in_first_name || ' ' || in_last_name,
+ SET name = in_first_name || ' ' || in_middle_name || ' ' || in_last_name,
country_id = in_country_id
WHERE id = in_entity_id;
ELSE
INSERT INTO entity (name, entity_class, country_id)
- values (in_first_name || ' ' || in_last_name, 3, in_country_id);
+ values (in_first_name || ' ' || in_middle_name || ' ' || in_last_name, 3, in_country_id);
e_id := currval('entity_id_seq');
END IF;
@@ -70,8 +70,8 @@
ELSE
-- Do an insert
- INSERT INTO person (salutation_id, first_name, last_name, entity_id)
- VALUES (in_salutation_id, in_first_name, in_last_name, e_id);
+ INSERT INTO person (salutation_id, first_name, middle_name, last_name, entity_id)
+ VALUES (in_salutation_id, in_first_name, in_middle_name, in_last_name, e_id);
RETURN e_id;
@@ -86,6 +86,29 @@
) IS
$$ Saves the person with the information specified. Returns the entity_id
of the record saved.$$;
+
+
+CREATE OR REPLACE FUNCTION person__list_locations(in_entity_id int)
+RETURNS SETOF location_result AS
+$$
+DECLARE out_row RECORD;
+BEGIN
+ FOR out_row IN
+ SELECT l.id, l.line_one, l.line_two, l.line_three, l.city,
+ l.state, l.mail_code, c.id, c.name, lc.id, lc.class
+ FROM location l
+ JOIN person_to_location ctl ON (ctl.location_id = l.id)
+ JOIN person p ON (ctl.person_id = p.id)
+ JOIN location_class lc ON (ctl.location_class = lc.id)
+ JOIN country c ON (c.id = l.country_id)
+ WHERE p.entity_id = in_entity_id
+ ORDER BY lc.id, l.id, c.name
+ LOOP
+ RETURN NEXT out_row;
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
CREATE OR REPLACE FUNCTION person__list_locations(in_entity_id int)
RETURNS SETOF location_result AS
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ledger-smb-users mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-users