Thursday, May 20, 2010

Dynamic concatenation of columns in oracle for a given Table

We can use the following anonymous block to concatenate all the columns in a given table.

The below anonymous block takes tablename as a parameter and gives all column names separated by comma.


declare
v_RETURN_STRING varchar2(200);
begin
for rec in (select column_name
from user_tab_columns
where table_name = 'TABLE_NAME')
loop
if v_RETURN_STRING is null then
v_RETURN_STRING := rec.column_name;
else
v_RETURN_STRING := v_RETURN_STRING ||','|| rec.column_name;
end if;
end loop;
dbms_output.put_line(v_RETURN_STRING);
end;

Using RegMatch in Informatica to validate email address

The function below validates the email address in informatica.

This is used to check if the email address is valid (has @ and .com/.edu/.org or so and has some valid characters/numbers before and after). This doesnt ping and verify if this is a "REAL VALID and WORKING" email address or domain name.

This Function takes email address as input and validates the Email. If the Email is valid, the output of this expression will be 'Valid' else 'Invalid'.

IIF(reg_match(in_Email,'^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$'),'Valid','Invalid')

This kind of stuff is primarily used for informatica on cloud - like salesforce.com or success factors where uploading data to salesforce.com requires valid definition of data elements we upload.