The reason is that when you create a parameter with Direction equal to ReturnValue, this parameter means the return value of the whole command. You have the following command:
Code: Select all
insert into actors
first_name,
last_name)
values
(:new_first_name,
:new_last_name)
returning actor_id;
insert into logs
(msg)
values
(:actor_id);
Your command consists of the two statements. The INSERT with RETURNING is executed first. Since there is another statement after it, this returning is ignored, and the second statement is executed. Its result is the resultset of the whole command. Out and ResultValue parameters in PostgreSQL are simply passed back to the client, and you cannot just use them in the command text.
To implement such logics, you can use the following anonymous code block:
Code: Select all
DO $$DECLARE temp integer;
BEGIN
insert into actors
first_name,
last_name)
values
(:new_first_name,
:new_last_name)
returning actor_id into temp;
insert into logs
(msg)
values
(temp);
END$$;
This anonymous block will insert data to the actors table and adds the corresponding record to a log. However, when testing an anonymous code block, we found a bug in dotConnect for PostgreSQL with parsing $$ characters in an anonymous code block. We will fix it and post here about the results as soon as possible.