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!

String concatenation as inline view

523861Feb 1 2010 — edited Feb 1 2010
Hi all, I have a bit of code using the standard string concatenation connect by code, but I also want to include other columns from other tables for example:
Select c.id,
         c.name,
         cp.type
         cp.number
         add.Addressline
  from customer c,
         cus_phone cp
      ,(select cus_id, 
               ltrim(max(sys_connect_by_path(Address,' ~ ')) keep (dense_rank last partition by cus_id),' ~ ') addressline
        from      (select cus_id, address, row_number() over (partition by cus_id order by seq_no) as rn
                   from   customer_address)
        connect by cus_id = prior cus_id and rn = prior rn + 1
        start with rn = 1
        group by   cus_id) add
 where c.id = add.cus_id;
Now the problem with this is it does a full table scan on the customer_address table. when I insert a "where cus_id = c.id" in the connect by view it obviously doesn't know what it is. "invalid identifier"

is there anyway I can inject that predicate to prevent the full table scan but still keep it all in one query. (preferably without using model clause aggregation).
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2010
Added on Feb 1 2010
14 comments
949 views