diff options
Diffstat (limited to 'db_demo/sql/funcs/cr_func_insert_person.sql')
-rw-r--r-- | db_demo/sql/funcs/cr_func_insert_person.sql | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/db_demo/sql/funcs/cr_func_insert_person.sql b/db_demo/sql/funcs/cr_func_insert_person.sql new file mode 100644 index 0000000..762bf42 --- /dev/null +++ b/db_demo/sql/funcs/cr_func_insert_person.sql @@ -0,0 +1,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;
\ No newline at end of file |