in reply to Re: INSERT with RETURNING INTO clause
in thread INSERT with RETURNING INTO clause

Thank you for your reply. It was much more useful than the flaming going on in the chatterbox. The solution is as follows:

1. Change the sql, so that there are 3 placeholders in the values clause:

my $sql = qq { INSERT INTO peck_test VALUES ( ?,?,? ) RETURNING my_id INTO ? };

2. Change the binding as follows:

$sth->bind_param (1, $id, SQL_NUMERIC); $sth->bind_param (2, $name, SQL_VARCHAR); $sth->bind_param (3, $desc, SQL_VARCHAR); $sth->bind_param_inout(4, \$id, SQL_NUMERIC);
Thanks again, Akoya

Replies are listed 'Best First'.
Re^3: INSERT with RETURNING INTO clause
by GotToBTru (Prior) on Feb 24, 2014 at 16:34 UTC

    I would also name the fields in the insert statement. It helps self-document and would simplify the command since you could omit the field populated by the trigger. And, it will keep you from having to revise this code should another field be added to the table. Also, if one of the fields you use is renamed or removed, the error messages might be more explicit.

A reply falls below the community's threshold of quality. You may see it by logging in.