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');

Tuesday, September 10, 2013

How to Refresh Coach Designer HTML (TW 6.2.2)

Problem Statement
You want to refresh the HTML generated by combining the Coach's XML and CoachDesigner.xsl

How To Do That?
Use "touch" command on *nix platforms to update timestamp of CoachDesigner.xsl file. The HTML will be refreshed next time any user requests for that Coach.

Useful SQL
select
 pi.name,
 p.last_modified AS "Service Modified On",
 pi.twcomponent_id,
 pi.process_item_id,
 pi.last_modified AS "Coach Last Modified On",
 cr.resource_data,
 cr.virtual_name,
 cr.last_modified AS "Coach XML/HTML Modified",
 cr.coach_resource_id
from
 tw_proc.lsw_process_item pi,
 tw_proc.lsw_process p,
 TW_PROC.lsw_coach_resource cr
where
  pi.process_id = p.process_id and
  pi.twcomponent_name = 'Coach' and
  p.name = '<NAME OF SERVICE>' and
  pi.twcomponent_id = cr.coach_id;