On Thu, Dec 26, 2019 at 9:33 AM stan <st...@panix.com> 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.

Reply via email to