I am a beginner for postgresql and I would like to create a procedure in sql. I created a function that inserts a record into a table and it returns the id. But there is something wrong, I don't want any result except for the output parameter.
CREATE OR REPLACE FUNCTION public."InsertVideo"
(
OUT out_scope_id integer,
IN in_youtubeidvideo varchar[],
IN in_title varchar,
IN in_rating double precision,
IN in_viewcount integer
)
RETURNS integer AS
$$
DECLARE
id INTEGER;
INSERT INTO Video
(
YoutubeIdVideo,
Title,
Rating,
ViewCount,
DataAdded,
ConvertedFlag,
SchedulingFlag
)
VALUES
(
in_youtubeidvideo,
in_title,
in_rating,
in_viewcount,
now(),
false,
false
);
SELECT id := CURRVAL(pg_get_serial_sequence('public.video','IDVideo'));
RETURN id;
$$
LANGUAGE 'sql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER;