I working with creating new SP which will insert or do a select and return ID of the founded/inserted record. Parameter ID is inout parameter of stored procedure.
I was helped with https://stackoverflow.com/questions/57476508/invoke-stored-procedure-and-return-id
I have prepared table , stored procedure and select statement: https://dbfiddle.uk/XHPxeW_b
but getting error, i nearly come to end of the internet and did not found a proper solution. Error:
do $$
declare _id int;
Begin
call InsertSelectCategory('Add-Hoc', _id);
select _id
end;
$$ LANGUAGE plpgsql;
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function inline_code_block line 6 at SQL statement
Thanks for helping me.
nameand usingINSERT ... ON CONFLICT. Also: you don't need to makeidunique if it's already the the primary key. dbfiddle.uk/a5dTqxN6