aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_save_rategroup_json
Parameters
Name
Type
Mode
p_data
jsonb
IN
Definition
declare v_result json; v_msg_text text; v_sqlstate text; v_detail text; v_hint text; v_context text; v_rategroup_id int; v_name text; /* { "name" : "TestRateGroup23033" } */ begin -- p_data ->> 'name' มีค่าเป็นสตริงว่าง ('') จะแปลงค่านั้นเป็น NULL -- ถ้ามีค่าอื่นนอกจากสตริงว่าง จะคงค่าเดิมไว้ -- กรณีนี้จะส่งคืน NULL --SELECT NULLIF('hello', 'hello'); -- กรณีนี้จะส่งคืน 'hello' --SELECT NULLIF('hello', 'world'); v_name := NULLIF(p_data ->> 'name', ''); insert into rate_group("name") values(v_name); return fn_result_success(); exception when others then get stacked diagnostics v_msg_text = message_text, v_sqlstate = returned_sqlstate, v_detail = pg_exception_detail, v_hint = pg_exception_hint, v_context = pg_exception_context; return fn_handle_error( v_sqlstate, v_msg_text, v_detail, v_hint, v_context, 'sp_save_rategroup_json', null ); END;