Informatica column splitting - informatica-powercenter

I have a source which has only one column as shown below
Col1
123#abcdef$68#ghij
trsp#728&hmbb6378
$##1267rtxc
I want to load this source to below target table with three columns . col1 should hold only alphabets , col2 should hold only numeric , col3 should hold only special characters
col1 col2 col3
Please tell me the approach in Informatica .

Use REPLACECHR like in this link https://forgetcode.com/informatica/1816-replacechr-replace-characters-in-a-string-with-some-other-character-or-remove-them
First replace all characters a to z and 1 to 9 with blank to get a variable port lets call portB with only the special characters. Then use the portB as the replacecharacters in a second variable lets call portC based on the original input port. Create your numbers port lets call portD by replacing all characters of portC with blank. Create your alphabets port lets call portE by replacing all the numbers of portC with blank. Create one output port portF to be equal to portB. Connect portD, portE and portF to your target

Related

Oracle APEX number format mask without comma

I am trying to change the number eg. 1000 to 1.000, 10000 to 10.000 istead of 10,000 or 10,000.00
DO you have any idea? :)
As far as I can tell, there's (unfortunately) no declarative way to modify thousands/decimal separators. Should be somewhere in "Edit application definition - Globalization" settings, but - there's nothing like that there.
So, do it yourself, manually. Navigate to shared components - security attributes - database session tab - initialization PL/SQL code and put this into it:
begin
execute immediate q'[alter session set nls_numeric_characters = ', ']';
end;
which will set comma as decimal separator, and space as thousands (group) separator.
Example:
SQL> alter session set nls_numeric_characters = ', ';
Session altered.
SQL> select 5000 val1,
2 to_char(5000, '999G990D00') val2,
3 to_char(5000, '999G990') val3
4 from dual;
VAL1 VAL2 VAL3
---------- ----------- --------
5000 5 000,00 5 000
SQL>
You can use
SELECT TO_CHAR(your_nr_col, '999G999G999G990', 'nls_numeric_characters='',.''') AS nr_formatted
FROM t
if you're dealing with integers only ( without including any decimal separator ), put as much as 9s to exceed the number of the digits while adding Gs after each three padded digit starting from the right hand side.
If there might arise some cases in which the decimal separators are needed, then replace the second argument with '999G999G999G990D0000' to pad enough 0s after single D character directing from left to right
DemO

Oracle LPAD() function

Question: For every part description that begins with the letter β€œb”, list the part description, and then pad each part description with a β€œ+”on the left side so that all these part descriptions are 15 characters in length.
And I wrote like
SELECT
LENGTH(PART_PART_DESCRIPTION), LPAD(PART_PART_DESCRIPTION,15,'+'),
PART_PART_DESCRIPTION, CONCAT('+', PART_PART_DESCRIPTION) FROM PART
WHERE SUBSTR(PART_PART_DESCRIPTION,1,1)='B'
but the output doesn't show 15 of '+' on left side.
Here is the output table
Your column PART_PART_DESCRIPTION is of CHAR data type with 285 data length. so BLENDER in your column has a total 285 (7 + 278 trailing spaces) length. that is why you are facing the problem.
See this:
SQL> select LPAD(CAST('BLENDER' AS CHAR(285)),15,'+') FROM DUAL;
LPAD(CAST('BLENDER'ASCHAR(285)),15,'+')
------------------------------------------------------------
BLENDER
SQL> select LPAD('BLENDER',15,'+') FROM DUAL;
LPAD('BLENDER',
---------------
++++++++BLENDER
SQL>
You need to use TRIM to properly use the LPAD on CHAR datatype column Something like the following:
LPAD(trim(PART_PART_DESCRIPTION),15,'+')
Most probably your data is padded with spaces. Try this
SELECT
LENGTH(PART_PART_DESCRIPTION), LPAD(TRIM(PART_PART_DESCRIPTION),15,'+'),
PART_PART_DESCRIPTION, CONCAT('+', PART_PART_DESCRIPTION) FROM PART
WHERE SUBSTR(PART_PART_DESCRIPTION,1,1)='B'

Supress leading zeros from oracle table extract to a file

I am extracting data from oracle table to a text file and I have below number columns. When I select the below columns to a file it gives me all leading zeros which I wanted to suppress.
Select ltrim(col_1,'0'),ltrim(col_2,'0'),ltrim(col_3,'0') from table1
Datatype:
Col_1 ---NUMBER(10,2),
Col_2 ---NUMBER(38,0),
Col_3 ---NUMBER(15,1)
Current Output:
00000303.44|0| 00000000000008.2
00000000.00|26| 00000000000030.2
00000473.40|0| 00000000000010.0
Expected Output:
303.44|0|8.2
0|26|30.2
473.4|0|10
Please let me know if i need to change the datatype to get the Expected output. I even tried TO_CHAR(TRIM(LEADING 0 FROM col_name) i did not get the expected output.
This is caused by the datatypes set in the last output stage of your datastage job. When a column is set a decimal, datastage will fill the remaining positions with leading zeros up to the size if your decimal field.
The easiest way to get around this is to place a transform prior to the file output stage and convert all the columns to a varchar at the last stage trimming all the leading zeros.
Since the data is not in number and possibly in varchar/varchar2;
conversion is required; you can use to_number to address this;
Using one of your sample data in below case
select
to_number(00000000000008.2) as num1,
to_number('00000000000008.2') as chr1,
trim(00000000000008.2) as num2,
trim('00000000000008.2') as chr2,
ltrim(00000000000008.2,'0') as num3,
ltrim('00000000000008.2','0') as char3
from dual

Oracle comment to Find first charater start with Alpha and second with numeric

I have table called DOMcolumn name position
I have below list of values in Position column
SN125A,A1234,SSD123,B12347,SDDF234,11123,E1O123,B12345
my requirement is to find the positions whose First letter is Alpha and second letter is numeric.
So My expectation Positions is
A1234,B12347,E1O123,B12345
Once I find these position then I need to remove the first character of the above positions
So my final output should be :
1234,12347,1O123,12345 (removed the alpha from above positions)
How do we achieve this in Oracle.
I tried the below REGEXP_LIKE(POSITIONS, '[A-Za-z]') in my query but I'm not sure about it.
You should match the beginning of the line ^ and also test for following digits
^[A-Za-z][0-9]
You can so add a third parameter to make the matching case-insensitive:
REGEXP_LIKE (POSITIONS, '^[A-Z][0-9]', 'i');
You can remove the first char by using SUBSTR
SUBSTR(POSITIONS, 2) AS pos
dom is the table name, position is the column name
select * from dom;
position
----------
SN125A
A1234
SSD123
B12347
SDDF234
11123
E1O123
B12345
8 rows selected.
1 select substr(position, 2,length(position)) from dom
2* where regexp_like(position,'^[[:alpha:]][[:digit:]]')
SQL> /
SUBSTR(position,2,LENGTH(position))
--------------------------------------------
1234
12347
1O123
12345

Multiple lines in a column in oracle to a single row

My oracle table is as follows ( Address column having multiple lines):
ID Address
--------------------
1456897 No 61
11th Street
Tatabad Coimbatore - 641012
How to get the desired result as (with Address column as a single line) ?
ID Address
-------------------------
1456897 No 61 , 11th Street, Tatabad Coimbatore - 641012
I don't know if your database has its newlines as \x0a or \x0d or \x0d\x0a. I therefore propose a the following solution that handles all three kind of new lines. It will however replace mutliple newlines with one ,. This might be what you want, or it might not.
select
id,
regexp_replace(
address,
'('||chr(10)||'|'||chr(13)||')+',
', ') as address,
....
from
....
remove new line character in the column - something like
SELECT REPLACE(Address_column, '\n', ' ') -- \n might be also \r\n or even \r
FROM table_name

Resources