Showing posts with label CONNECT. Show all posts
Showing posts with label CONNECT. Show all posts

Wednesday, October 23, 2013

Connect to Oracle RAC Database server

Oracle RAC database uses service-name instead of service-id. Hence, you would need a connection string formatted for using service-name.

Lets say your non-RAC server was hosted on "abc.xyz.com" @ port 1521 and your SID is oradb01, then your connection string would have been :
  jdbc:oracle:thin:@abc.xyz.com:1521:oradb01

On a oracle RAC database server with service-name as oradb01, your connection string would be :
 jdbc:oracle:thin:@//abc.xyz.com:1521/oradb01

Note : I assume you are using Oracle thin driver for Java.

Friday, September 27, 2013

Oracle Convert CSV to ROW

Allow Only Numeric values in the CSV : 
WITH parameter_csv AS (select :1 as val from dual)
SELECT  REGEXP_REPLACE(REGEXP_SUBSTR( val, '[^,]+', 1, LEVEL ),'[^0-9]','')  AS id
           FROM    parameter_csv
           CONNECT BY LEVEL <=
                LENGTH( REGEXP_REPLACE(val, '[^,]+', '' ) ) + 1


If you can afford it not to be parametrized (no ? marks in SQL) Needs Oracle 11g:
select * from xmltable('"this","is","my","csv"');
or 
select * from xmltable('1,2,3,4');