Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue with multiple with clause usage

Orcl ApexJul 28 2016 — edited Jul 28 2016

Hi All,

I am facing below issue in using WITH clause, please advise what I am doing wrong.

Error at line 20 and 28

  • PL/SQL: ORA-00904: "M1"."INVENTORY_ITEM_ID": invalid identifier
  • PL/SQL: ORA-00904: "M3"."RELATED_ITEM_ID": invalid identifier

WITH m1 AS

      (SELECT segment1,

        inventory_item_id,

        organization_id

      FROM mtl_system_items_b

      WHERE organization_id = cn_organization_id

      AND inventory_item_id = in_item_id

      ),

      m3 AS

      (SELECT inventory_item_id,

        related_item_id,

        organization_id,

        relationship_type_id,

        reciprocal_flag,

        start_date,

        end_date,

        attr_char3,

        attr_char1

      FROM mtl_related_items

      WHERE inventory_item_id = m1.inventory_item_id

      ),

      m2 AS

      (SELECT segment1,

        inventory_item_id,

        organization_id

      FROM mtl_system_items_b

      WHERE organization_id = cn_organization_id

      AND inventory_item_id = m3.related_item_id

      ),

This post has been answered by AndrewSayer on Jul 28 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2016
Added on Jul 28 2016
7 comments
552 views