CREATE OR REPLACE FUNCTION nn_db.user_post(
	in_lastname nn_db.user.lastname%TYPE
	, in_firstname nn_db.user.firstname%TYPE
	, in_middlename nn_db.user.middlename%TYPE
	, in_username nn_db.user.username%TYPE
	, in_password_hash nn_db.user.password_hash%TYPE
	, in_email nn_db.user.email%TYPE
	, in_phone nn_db.user.phone%TYPE)
RETURNS TABLE(pk_user nn_db.user.pk_user%TYPE)
AS $$
BEGIN
	INSERT INTO nn_db.user(
		lastname
		, firstname
		, middlename
		, username
		, password_hash
		, email
		, phone
		, is_admin
		, is_active)
	VALUES(
		in_lastname
		, in_firstname
		, in_middlename
		, in_username
		, in_password_hash
		, in_email
		, in_phone
		, False
		, False);
		
	RETURN QUERY SELECT MAX(nn_db.user.pk_user) FROM nn_db.user;
END;
$$ LANGUAGE plpgsql