summaryrefslogtreecommitdiffstats
path: root/db_demo/sql/funcs/cr_func_insert_person.sql
blob: 762bf42d245d83bd14191f6241e76a87c8dd98a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CREATE OR REPLACE FUNCTION insert_person (
  boolean,   -- cexperience
  boolean,   -- wexperience
  integer    -- agegroupid
) RETURNS integer AS $$
DECLARE
  par_cexperience  ALIAS FOR $1;
  par_wexperience  ALIAS FOR $2;
  par_agegroupid   ALIAS FOR $3;

  var_personid     integer;
BEGIN
  INSERT INTO tbl_person (
    cexperience,
    wexperience,
    agegroupid
  ) VALUES (
    par_cexperience,
    par_wexperience,
    par_agegroupid
  );

  SELECT INTO var_personid seq_person.last_value;

  RETURN var_personid;
END;
$$ LANGUAGE plpgsql;