DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 11

Thread: query help

Threaded View

  1. #7
    Join Date
    Apr 2006
    Posts
    377
    Code:
    SQL> select * from hosts;
    
    HOSTID
    --------------------------------------------------------------------------------
    host1:12.134.23.45,host2:34.56.76.102:1521,hosts3,hosts4:10.2.1.0,12.3.4.3:3030,
    hosts5.local:198.162.10.1:1521,hosts6.local.com,host7:3000
    
    SQL> with t as (
      2         select regexp_substr(hostid, '[^,]+', 1, level) str
      3         from hosts
      4         connect by level <= length(hostid)-length(replace(hostid,','))+1)
      5  select regexp_substr(str, '.*[a-z]+[^:]*',1,1,'i') hostname
      6  ,      ltrim(regexp_substr(str, '(^|:)[0-9]+[.][^:]+'),':') ip
      7  from t;
    
    HOSTNAME             IP
    -------------------- --------------------
    host1                12.134.23.45
    host2                34.56.76.102
    hosts3
    hosts4               10.2.1.0
                         12.3.4.3
    hosts5.local         198.162.10.1
    hosts6.local.com
    host7
    
    8 rows selected.
    Last edited by ebrian; 06-24-2010 at 11:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width