Need help on the regular expressions and query
Hi guru s, I hope that you all made great!I have a scenario where I need to insert data into the table.
I have three scenarios:
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
Alex Romano
Kodali,Raj,S
ppppp
What I want is now.1 Alex Romano
is there space between the chain and then I want to insert in the last name and first name columns
2 Xavier, Raj, S
If there is a comma between the chain and I want to insert in the last name, first name and middle name
3. If there is one channel then insert even in first name and last name.
I wrote the request more early to manage only by commas and now I'm trying but not able to use this all scenarios
Can you please help me.
WITH t AS (
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
)
select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
from
(
SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
, max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
, max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME
FROM t
CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
GROUP BY str
) ;
Currently I put a b and c if its null value.Thanks in advance!
Hello
You can do what you asked for in pure SQL like this:
WITH got_pos AS
(
SELECT str
, INSTR (str, ',') AS comma_pos
, INSTR (str, ' ') AS space_pos
FROM t
)
SELECT str
, CASE
WHEN comma_pos > 0
THEN REGEXP_SUBSTR (str, '\w+', 1, 2)
WHEN space_pos > 0
THEN SUBSTR (str, 1, space_pos - 1)
ELSE str
END AS fname
, CASE
WHEN comma_pos > 0
THEN REGEXP_SUBSTR (str, '\w+', 1, 3)
ELSE TRIM (REGEXP_SUBSTR (str, ' \w+ '))
END AS mname
, CASE
WHEN comma_pos > 0
THEN SUBSTR (str, 1, comma_pos - 1)
ELSE REGEXP_SUBSTR (str, '\w+$')
END AS lname
FROM got_pos
ORDER BY str
;
But look how it is difficult, even for this simple example of data.
I suggest you write a PL/SQL function to analyze the name. It will be much easier to deal with a combination of spaces and commas, the names of more than 3 words, etc.
Tags: Database
Similar Questions
-
Help with the Regular Expressions and regexp_replace
Oh great guru Oracle can I can receive assistance
I need to clean the phone numbers that have been entered in the table per_phones of Oracle e-Business. Some of the phone numbers have hyphens, some have spaces and some have tank. I just want to get out all the figures and then re - format the number.
E.g.
914-123-1234... out (914) 123-1234
9141231234... new (914) 123-1234
914 123 1234... (914) 123-1234
MyPhone... just null
(914)-123-1234... (914) 123-1234
I really tried to understand the instructions of regular expressions, but for some reason, I can't understand it.For example:
SQL> with sample_data as ( 2 select '914-123-1234' phone_number from dual union all 3 select '9141231234' from dual union all 4 select '914 123 1234' from dual union all 5 select '(914)-123-1234' from dual 6 ) 7 select regexp_replace( 8 regexp_replace(phone_number, '\D') 9 , '(...)(...)(....)' 10 , '(\1) \2-\3' 11 ) as formatted_num 12 from sample_data 13 ; FORMATTED_NUM -------------------------------------------------------------------------------- (914) 123-1234 (914) 123-1234 (914) 123-1234 (914) 123-1234
-
Need help with the OSB Assign and replace the
I have a proxy service that receives the SOAP message:
" < = xmlns:soapenv soapenv:Envelope ' http://schemas.xmlsoap.org/SOAP/envelope/ "xmlns:SOAP - ENC =" " http://schemas.xmlsoap.org/SOAP/encoding/ "container =" " http://www.w3.org/1999/XMLSchema ">
" < = xmlns:soapenv soapenv:Header ' http://schemas.xmlsoap.org/SOAP/envelope/ ">
< / soapenv:Header >
< soapenv:Body >
" < pidx:OrderChange pidx:transactionPurposeIndicator = 'Replace' xmlns:pidx = ' http://www.API.org/pidXML "xmlns =" http://www.API.org/pidXML "" xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance "xsi:schemaLocation="C:\shareIt\OrderChange_1-2.xsd" > ""
...
< / pidx:OrderChange >
" < = Xmlns:ocp DeliveryInformation ' http://www.digitaloilfield.com/OCP ">
...
< / DeliveryInformation >
< / soapenv:Body >
< / soapenv:Envelope >
I need to take the OrderChange element and place it in a SOAP body and the DeliveryInformation element and place it in the SOAP of the same SOAP message header.
The SOAP message is then sent to a business service that makes an HTTP POST of the SOAP XML.
I created the service of the company and he sent some data test SOAP and it works very well, but cannot create a bridge between the Proxy and the Business Service.
In the stream of messages of Proxy I tried to do an assignment in a routing. I tried to do the following:
1. an XQuery query transform to generate the XML SOAP just described
2. not the entitlement where the "Expression" is the transformation and the Variable is a variable based on a schema for SOAP.
I can see that the company is trying to be invoked, but the SOAP data does not have to be formatted or passed.
It is the right approach or is their a better way of
1. create the SOAP wrapped XML
2. call the Business Service.
Any suggestions are appreciated. I can provide more detail if necessary.
Kind regards.
Thank you Vlad...
I think I'm getting in that direction now. Just do some debugging.
Appreciate the input. I will update with final results.
Again, your help is greatly appreciated.
Kind regards.
-
The Regular Expressions and GUID.
Hello gurus, I hope you can help me!
I need to select GUID from a table and to do this, I need the regular Expression. My
Perl is not good and not good Regular Expression. My database is Oralce 11.2.0.2.0 and
Linux (Oracle Version 6) is the operating system of the Machine. If you need further information,
I'll look closely. Thank you. Jehangir.>
Hi Jehangir and welcome to the forums.
I need to select the GUID of a table and to do this,
Well, the first thing we do is read the forum FAQ and also the post by BluShadow
at the top of the messages on the home page of the forum. You should have provided code (DDL
and DML) showing your particular problem, but since it's your first time, I'll be gentle ;)We have it done - clients have sometimes GUID as PKs, and we need to send data to
their systems, but it is not as simple as it may first appear.GUID may arise in three formats.
The Oracle one - SELECT Sys_GUID() from DUAL which is just a string of 32 hexadecimal characters.
Then the chain with the hyphen, then the string with dashes and {} at the beginning and end (see
examples of data).with datax as ( SELECT '79A864CCD8E44CD8B0A2765DF9EF337B' as guid FROM DUAL UNION ALL SELECT '79A864CFD8E44CD7B0A2765DF9EF337B' FROM DUAL UNION ALL SELECT '8gdfsgsgfdg' FROM DUAL UNION ALL -- dummy for testing SELECT '21EC2020-3AEA-1069-A2DD-08002B30309D' FROM DUAL UNION ALL SELECT '21EC5550-3AEA-1069-A2FF-08002B30309D' FROM DUAL UNION All SELECT '{21CC2020-3AFA-1A69-A2DD-08002B30309D}' FROM DUAL ) -- first one is the Oracle format select * from datax where regexp_like(guid, '[0-9a-fA-F]{32}'); -- Oracle select sys_guid(); -- second one is with hyphens select * from datax where regexp_like(guid, '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}'); -- third one is with hyphens and curly brackets. select * from datax where regexp_like(guid, '^\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}$'); -- This converts both of the last two formats back into Oracle format, which is what -- we use. Notice, that I haven't used regualar expressions to do this. Regexes are -- computationally expensive, and you should use Oracle's string furnctions if possible SELECT REPLACE(REPLACE(REPLACE(GUID, '{', ''), '}', ''), '-', '') FROM Datax;
HTH,
Paul...
Jehangir.
-
Form validation helps with the regular Expression [a-zA-Z]
I'm trying to use the regular expression [a-zA-Z] to allow only upper or lowercase WITHOUT SPACES. With the help of [a-zA-Z] allows space and numbers.
Could someone give me a point in the right direction?
Thank you!
RGNelson wrote:
I'm trying to use the regular expression [a-zA-Z] to allow only upper or lowercase WITHOUT SPACES. With the help of [a-zA-Z] allows space and numbers.
Could someone give me a point in the right direction?
Please try with the following regular expression, which should work for text entry fields 'a line' well standard.
^ [A-Za-z] + $
See you soon,.
Günter
-
Need help with a regular expression
I have a Zebra printer string that I want to analyze some information, but I can't get a single regex to do.
The string is like the following:
↑ FT342, 695 ^ A0N, 83, 81 ^ FH\ ^ FDS/N: [[WIDGET]] ^ FS
^ FT793, 1170 ^ A0N, 67, 67 ^ FH\ ^ ea FD1. Widget #00123 ^ FS
^ FT793, 1170 ^ A0N, 67, 80 ^ FH\ ^ ea FD2. #00456 Widget Deluxe ^ FS
^ FT793, 1170 ^ A0N, 67, 90 ^ FH\ ^ FD #0789 ^ FS
I want what is in red. It will vary from one label to the label. I will use the results to show to the user what label it is printing. Who is blue only varies, if that helps anything.
Thanks for any help!
Here would be a way using regular expressions. Again, you have to ignore the first entry and this version will add a blank entry in the last position of the table. Wil you have more entries if your label contains more than what you have posted...
-
The clob data analysis - helps in the regular Expression
Hello
Need to analyze a clob and and get its value.
with the temp as
(select '-dn=cn=9245fe4a-d402-451c-b9ed-9c1a04247482,ou=people,dc=idauth-userstore,dc=standardlife,dc=com' as double val)
Select * Temp;
"Analysis to include only the characters after ' dn = cn =" and ending with a comma, so I need to value the O/P as feadcbedca
How to achieve this using regular expressions.
Also is it a useful site to learn Oracle regular expressions for beginners like me.
If yes give me the link, it will be useful.
Thanks in advance
SQL> with temp 2 as 3 ( 4 select '- dn=cn=9245fe4a-d402-451c-b9ed-9c1a04247482,ou=people,dc=idauth-userstore,dc=standardlife,dc=com' as val from dual 5 ) 6 select regexp_replace(ltrim(regexp_substr(val, 'dn=cn=[^,]+'), 'dn=cn='), '[^[:alpha:]]') val 7 from temp; VAL ---------- feadcbedca SQL>
-
HP 15 - ac043tu: need help with the key feature and WiFi Drivers
Hi team,
I try to activate the key feature and WiFi in my new HP 15 - ac043tu laptop.
I use Windows 7 Ultimate 32 operating system.
I installed all the drivers available on the site Web of HP (http://support.hp.com/us-en/drivers/selfservice/HP-15-ac000-Notebook-PC-series/7771404/model/8326116... for my product.
To activate the function key, I installed driver: HP System Event Utility - sp71716, but it doesn't seem to work.
In Device Manager, network controller shows exclamation as shown below. I tried to install Broadcom and Realtek WLAN drivers, tried to turn on/off, uninstalled/reinstalled drivers referring to other positions, but that did not work.
I also tried to install HP SoftPaq Download Manager, but it did not help. Tool does not show my product described.
I went through a similar question posted by other members, but failed to get the solution. This question gave me hard times.
Appreciate your help in this regard.
Thank you
Kishan
Hello:
You need these drivers wireless and bluetooth driver 64-bit file should have the 32-bit drivers too.
Network controller (wireless card):
FTP://FTP.HP.com/pub/SoftPaq/sp71501-72000/sp71528 .exe
Bluetooth:
This package contains the Broadcom bluetooth driver and software for the laptop models running a supported operating system. Broadcom Bluetooth 4.0 driver is required to activate the bluetooth 4.0 Broadcom devices and is compatible with Broadcom bluetooth 3.0 and earlier versions.
File name: sp71440.exe
Unfortunately, I can't help you with the next question. The system of the event utility would be the only software I can think that would have worked.
You can try the software HP Quick Launch, but I doubt it will work.
http://h20565.www2.HP.com/hpsc/SWD/public/detail?swItemId=ob_112835_1
-
BlackBerry Z10 need help with the facebook chat and notifications
Hey, guys.
Since I updated to version 10.2.1.2102 of the software I was not able to receive messages from the hub of blackberry facebook chat. Before the update whenever I had my phone connected to a wireless network it was automatically getting messages facebook on the hub. Now, although I can send messages and receive messages if this contact is online, once I close the conversation hub is gone and I don't get the messages, only the "new messages of * person *" e-mail after a certain time.
In addition, I don't get notifications about birthdays of the people. I get the "next event" x hours notification on the lock screen, if I go in the calendar I see the notification at the top of the page, but it does not sound to warn me of my birthdays from the contacts.
Can someone help me with this two problems? Thank you!
Fact. I needed to update the facebook app.
-
Need help with the COUNT in a query
Hi all
I have the following table. In this table, I try to get the number of records per month when its value (SIGNAGE_ONE_LANE_ROAD_AHEAD) is 'Yes' and gives me the number of fake. Anyone can you please point out where I'm wrong?
AUDIT_DATE SIGNAGE_ONE_LANE_ROAD_AHEAD SIGNAGE_LANE_CLOSED_AHEAD
05/01/2011 09:30 N/A N/A
09/02/2011-11:50 Yes Yes
21/02/2011-10:00 Yes Yes
22/02/2011-07:00 N/A N/A
07/03/2011-13:35 Yes n/a
08/03/2011 09:15 N/A N/A
09/03/2011 08:40 N/A N/A
10/03/2011-10:00 N/A N/A
11/03/2011 09:45 Yes Yes
16/03/2011 08:45 Yes n/a
17/03/2011 09:30 N/A N/A
17/03/2011 12:05 N/A N/A
17/03/2011-13:10 Yes n/a
21/03/2011 10:30 N/A N/A
22/03/2011 09:30 Yes n/a
04/04/2011 11:20 Yes Yes
05/04/2011 10:30 Yes Yes
05/04/2011-10:45 Yes Yes
08/04/2011 09:30 Yes Yes
08/04/2011 12:45 N/A N/A
13/04/2011 10:15 Yes Yes
21/04/2011 08:45 N/A N/A
and the DataSet I get isSELECT to_char(t.audit_date,'mm') as audit_month, t.signage_lane_closed_ahead, t.signage_one_lane_road_ahead, (CASE WHEN t.signage_lane_closed_ahead = 'Yes' THEN COUNT (t.signage_lane_closed_ahead) ELSE 0 END ) AS lane_closed_count FROM dw_safety_work_zone_audit t group by to_char(t.audit_date,'mm'), t.signage_lane_closed_ahead,t.SIGNAGE_ONE_LANE_ROAD_AHEAD ORDER BY to_char(t.audit_date,'mm')
AUDIT_MONTH SIGNAGE_LANE_CLOSED_AHEAD SIGNAGE_ONE_LANE_ROAD_AHEAD LANE_CLOSED_COUNT
S/O S/O 1 0
S/O S/O 2 0
Yes Yes 2 2
3 S/O S/O 0
3 s/o Yes 0
3 Yes n/a 3
3 Yes Yes 1
4 N/A N/A 0
4 Yes Yes 5
Thank youHello
thinkingeye wrote:
SELECT to_char(t.audit_date,'mm') as audit_month, t.signage_lane_closed_ahead, t.signage_one_lane_road_ahead, (CASE WHEN t.signage_lane_closed_ahead = 'Yes' THEN COUNT (t.signage_lane_closed_ahead) ELSE 0 END ) AS lane_closed_count FROM dw_safety_work_zone_audit t group by to_char(t.audit_date,'mm'), t.signage_lane_closed_ahead,t.SIGNAGE_ONE_LANE_ROAD_AHEAD ORDER BY to_char(t.audit_date,'mm')
You want to COUNT (CASE...), not CASE...
The above code uses a CASE expression to display 0 or a NUMBER. When he shows the COUNTY, it is the full NUMBER in this column, not something conditional.
You probably want somehting like:
... COUNT ( CASE WHEN t.signage_lane_closed_ahead = 'Yes' THEN t.signage_lane_closed_ahead END ) AS lane_closed_count
In addition, you want to GROUP BY t.singage_lane_closed_ahead? Doing so means that you will get separate lines of output (with separate heads) for the 'Yes' and 'n/a '.
Also, maybe you should use
TRUNC (t.audit_date, 'mm') instead of
To_char (t.audit_date, 'mm')I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Re: Satellite A500 - need help with the FN key and Toshiba programs
Hello
The fn key Eco and other buttons specialized such as the one that opens Windows Media Player have stopped responding on my PSAM3A-03P00E A500 running Windows Vista. I can always change the brightness of the screen with the FN key, but no menu appears at the top of the screen.
Also Toshiba programs that are intended to be run at the start as PC Health Monitor are not auto start, even if they are enabled in the Configuration (msconfig) system.
The Bluetooth Manager however initially runs upward.I have blue screen errors, but they are not a problem since I have updated the BIOS to 1.5 and uninstalled Zonealarms.
See you soon
Hello
Try reinstalling the additional package of Toshiba. AFAIK, this utility is responsible for these functions.
-
Need help with the error message and lose internet
c:\\Users\TheJohnsons\AppData\Roaming\d3dx9.dll
Keep this error message and lose internet. Can someone tell me how to get rid of it? Do an internet search revealed programs for free download that I know are malware. The other message is c:\\Windows\System32\Spoolsv.exe
Thanks in advance.
c:\\Users\TheJohnsons\AppData\Roaming\d3dx9.dll
Keep this error message and lose internet. Can someone tell me how to get rid of it? Do an internet search revealed programs for free download that I know are malware. The other message is c:\\Windows\System32\Spoolsv.exe
Thanks in advance.
Download and run the DirectX end-user running, to see if we can eliminate the d3dx9.dll message.
http://www.Microsoft.com/en-US/Download/details.aspx?ID=35
Regarding the message in spoolsv.exe, see thread below.
-
hp350g1: need help on the admin password and power on password
3 times to not receive a stop code 69074945
Thank you!
Try 76952381 password.
-
My mac mini (mid-2010) speed/performance is very slow - think of it as a result of letting my kids do "whatever" about it in recent years. Need help, consolidate the files, software updates, etc. in order to improve the speed and performance. You will also need to get data out of old PowerBook G4.
< object edited by host >
We are users like you. Search locally by using something like Yelp or similar
or read a few links which may be relevant on this forum about the slow mac mini
-
I'm on Acrobat 10 for mac and I need help with the distribution of shape feature. Is there a way to change the registration e-mail download addressed to the? Currently all forms I create and then distribute may only be subjected to my email account... I appreciate any help!
Do not use the feature distribute the form. Instead of this, just put up a button "submit" and configure it to send email using any email address you want. Just add a button and set the action of the mouse upward on "Submit a form" and use a type mailto URL and specify that you want to send the full PDF. Then activate the reader of the document: where "Advanced/extended features in Adobe Reader" is located in Acrobat XI?
If you really want to use distribute the form for some reason, change the e-mail address in your preferences: Edit > Preferences > identity > Email address
Maybe you are looking for
-
Hello for a while, I try to activate my personal cloud on my NAS ix-2. I tried to do as described in textbooks (which are not too useful). I already got it to the point where my 2 ix2 thought the installation was ok (but I still lost this configurati
-
Resolution error all windows update
Can someone a Windows update related error & resolution? Looks, Sohail Patel "a journey of a thousand miles begins with a first step".
-
At the opening of Director, that it does not open.
-
T60 1951-FEG W7 screen resolution
Is it possible to achieve a higher resolution 1078 x 768 on this machine with windows 7?
-
Who can help me to WHO: Sorry for fast hiking, misspellings, it's late and I do not use my normal computer to this problem I have. I am currently sympthym to start the black screen with a white cursor (furniture, put in construction in the middle) wi