Yes there are hundreds of questions like this one, however, they all have different syntax errors. Postgres’s syntax check is not giving me any hints on this one. The insert statements work fine, syntactically if I replace the ID with a fake constant. My error is in how I’ve added the do $$ declare begin end $$
construct here.
<code>do $$
declare new_inspection_template_id uuid;
begin
insert into inspection_template
(name, revision, description, product, notes)
values (
'QUAL349 RevC',
1,
'Quality checks for beveling.',
'sheet',
'There are no notes.'
) returning inspection_template_id into new_inspection_template_id;
insert into workflow (station, inspection_template_id)
values ('beveling', new_inspection_template_id);
end $$;
</code>
<code>do $$
declare new_inspection_template_id uuid;
begin
insert into inspection_template
(name, revision, description, product, notes)
values (
'QUAL349 RevC',
1,
'Quality checks for beveling.',
'sheet',
'There are no notes.'
) returning inspection_template_id into new_inspection_template_id;
insert into workflow (station, inspection_template_id)
values ('beveling', new_inspection_template_id);
end $$;
</code>
do $$
declare new_inspection_template_id uuid;
begin
insert into inspection_template
(name, revision, description, product, notes)
values (
'QUAL349 RevC',
1,
'Quality checks for beveling.',
'sheet',
'There are no notes.'
) returning inspection_template_id into new_inspection_template_id;
insert into workflow (station, inspection_template_id)
values ('beveling', new_inspection_template_id);
end $$;
Running this in my Rust SQL migration I get the error
<code>error: while executing migrations: error returned from database: syntax error at end of input
</code>
<code>error: while executing migrations: error returned from database: syntax error at end of input
</code>
error: while executing migrations: error returned from database: syntax error at end of input
Version:
<code>psql (PostgreSQL) 15.6 (Ubuntu 15.6-0ubuntu0.23.10.1)
</code>
<code>psql (PostgreSQL) 15.6 (Ubuntu 15.6-0ubuntu0.23.10.1)
</code>
psql (PostgreSQL) 15.6 (Ubuntu 15.6-0ubuntu0.23.10.1)