Re: Not my day :-( Another syntax error
"David G. Johnston" <[email protected]> Thu, 26 Dec 2019 10:26:49 -0700
| Newsgroups | gmane.comp.db.postgresql.general |
|---|---|
| Message-ID | <CAKFQuwZgmTxFSU94EXc9N6xE5JgSNC3NB7TqSkfjEvz-i+6--Q@mail.gmail.com> |
On Thu, Dec 26, 2019 at 9:33 AM stan <[email protected]> wrote: > > WITH inserted AS ( > INSERT into project_cost_category > (category) > VALUES > ('MISC') > RETURNING > * > ) > SELECT project_cost_category_key > INTO NEW.project_cost_category_key = > ( SELECT > project_cost_category_key > FROM > inserted ) > > You have two SELECTs. The "inner" one has a FROM clause attached to it providing columns from the "inserted" CTE. The "outer" one doesn't have a FROM clause and so doesn't have access to columns. The "outer" SELECT project_cost_category_key is thus invalid. David J.