2006-01-10 12:17:58 [DATA] (/home/richard/gnumed/gnumed/Gnumed/pycommon/gmPsql.py:address@hidden): create or replace function dem.set_nickname(integer, text) returns integer as ' DECLARE _id_identity alias for $1; _nick alias for $2; _names_row record; msg text; BEGIN -- 0.1: Just always set the nickname inside the active name -- post 0.1: openEHR-like (name: pk, fk_identity, name, fk_type, comment, is_legal, is_active ...) -- does name exist ? select into _names_row * from dem.names where id_identity = _id_identity and active = true; if not found then msg := ''Cannot set nickname ['' || _nick || '']. No active row with id_identity ['' || _id_identity || ''] found.'' raise exception msg; end if; -- can directly set nickname ? -- if _names_row.preferred is null then update dem.names set preferred = _nick where id = _names_row.id; return _names_row.id; -- end if; -- must create new row -- 1) deactivate old row ... -- update dem.names set active = false where id = _names_row.id; -- 2) insert new row from old row and new data ... --insert into dem.names (id_identity, active, firstnames, lastnames, preferred, comment) -- values (_id_identity, true, _names_row.firstnames, _names_row.lastnames, _nick, _names_row.comment); --if found then -- return currval(''names_id_seq''); --end if; --return NULL; END;' language 'plpgsql' 2006-01-10 12:17:58 [ERROR] (/home/richard/gnumed/gnumed/Gnumed/pycommon/gmPsql.py:address@hidden): ../sql/gmDemographics-Person-views.sql:159: ERROR: syntax error at or near "raise" a t character 112QUERY: SELECT 'Cannot set nickname [' || $1 || ']. No active row with id_identity [' || $2 || '] found.' raise exception $3 CONTEXT: SQL statement in PL/PgSQL function "set_nickname" near line 13