aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_save_guest_document
Parameters
Name
Type
Mode
doc_data
jsonb
IN
i_photo
bytea
IN (DEFAULT NULL)
guest_id
integer
IN (DEFAULT NULL)
Definition
declare v_map jsonb; v_address1 text; v_address2 text; v_guest_id int4; v_title_id int4; v_firstname text; v_lastname text; v_photo_path text; v_image_path text; v_doc_type int2; v_doc_number text; v_country_id int; v_nation_id int; v_sex char(1); v_date_of_birth date; v_date_of_expire date; begin v_map := fn_map_guest_document_fields(doc_data); v_doc_type := (v_map->>'doc_type')::int2; v_doc_number := v_map->>'doc_number'; v_sex := v_map->>'sex'; v_date_of_birth := (v_map->>'birthdate')::date; v_date_of_expire := (v_map->>'expire_date')::date; v_title_id := (v_map->>'title_id')::int4; v_country_id := (v_map->>'country_id')::int4; v_nation_id := (v_map->>'nation_id')::int4; v_firstname := v_map->>'first_name'; v_lastname := v_map->>'last_name'; v_address1 := v_map->>'address1'; v_address2 := v_map->>'address2'; ----- find existing guest profile IF guest_id IS NULL OR guest_id < 1 THEN guest_id := fn_find_guest_by_document(v_doc_type, v_doc_number, v_country_id); END IF; guest_id := sp_save_guest( i_guest_id => guest_id, i_last_name => v_lastname, i_first_name => v_firstname, i_title_id => v_title_id, i_sex => v_sex, i_birthdate => v_date_of_birth, i_nation_id => v_nation_id, i_address1 => v_address1, i_address2 => v_address2, i_country_id => v_country_id, i_doc_number => v_doc_number::citext, i_doc_type => v_doc_type, i_doc_expire => v_date_of_expire, i_doc_country => v_country_id, photo => i_photo ); return guest_id; end