Need help to parse a string in data
Hi all
I have some information coming out of a management system of files that looks like:
REGATTA PLAZA ETA (responsibility of: ETA Regatta Plaza, completed on 16/08/2013 09:11)
REVIEW of CSO (responsibility of: Matthews, Darlene, completed on 03/09/2013 10:53)
MOUNT PEARL ETA (responsibility of: Mount Pearl ETA, finished the 06/09/2013 12:28)
REVIEW of CSO (responsibility of: Matthews, Darlene, due 2013/09/10 12:29 (late 5 days, 2 hours, 10 minutes))
I added flashbacks for readability
I want to produce four rows of chain, with:
Action (the tip before the opening parenthesis)
Manager (the bit after "the responsibility of:"at the beginning of the parenthesis ")
A completion date, iff, it was completed or
A due date (if it was not completed and is always due)
I'm sure it can be done easily with REGEXP and sort of CONNECT BY tip to get multiple lines, but I'm not really up on top of one of these things. It gets quite messy using substr and instr (attempt below, I also know deals not with the second and fourth records (the person responsible is "Matthews, Darlene" that has a comma in there).)
Thank you very much
Jon
with parse_string as (select 'REGATTA PLAZA ETA (Responsibility of: Regatta Plaza ETA, Completed on 2013/08/16 9:11 AM.) CSO REVIEW (Responsibility of: Matthews, Darlene, Completed on 2013/09/03 10:53 AM.) MOUNT PEARL ETA (Responsibility of: Mount Pearl ETA, Completed on 2013/09/06 12:28 PM.) CSO REVIEW (Responsibility of: Matthews, Darlene, Due 2013/09/10 12:29 PM (Overdue 5 Days, 2 hours, 10 minutes))' ts from dual) -- select substr(ts,1,instr(ts,'(')-1) action, substr(ts,instr(ts,'(')+19,instr(ts,',',instr(ts,'(')+1)-instr(ts,'(')-19) responsible, CASE WHEN instr(ts,'Completed',instr(ts,',',instr(ts,'(')+1)+1) >0 then to_date(substr(ts, instr(ts,'Completed',instr(ts,',',instr(ts,'(')+1)+1) + 15, instr(ts,')',instr(ts,',',instr(ts,'(')+1) + 15) -- endpos - instr(ts,'Completed',instr(ts,',',instr(ts,'(')+1)+1) - 16),'yy/mm/dd hh:mi am') -- startpos else NULL end completed_date from parse_string;
Hello
If you are going to do this in pure SQL, you really want to use regular expressions, like this:
WITH separate_rows AS
(
SELECT REGEXP_SUBSTR (ts
, '[^)]*\)+ *'
1
LEVEL
) AS str
OF parse_string
CONNECT BY LEVEL<= regexp_count="" (ts,="">=>
)
SELECT REGEXP_SUBSTR (str
, '^[^(]*'
) AS action
REGEXP_SUBSTR (str,
, "The responsibility of: (.)» *) (, (completed |)) EUM))'
1
1
NULL
1
) Responsible.
TO_DATE (REGEXP_SUBSTR (str
, ' Finished (\d + / \d + / \d+ \d+:\d+ (AM |)) MP))'
1
1
NULL
1
)
, ' YYYY, MM, DD, HH: MI AM'
) AS completed_date
TO_DATE (REGEXP_SUBSTR (str
, ' Maturity (\d + / \d + / \d+ \d+:\d+ (AM |)) MP))'
1
1
NULL
1
)
, ' YYYY, MM, DD, HH: MI AM'
) AS end_date
OF separate_rows
;
Output:
ACTION COMPLETED_DATE MANAGER END_DATE
------------------ ------------------ ------------------- -------------------
REGATTA PLAZA ETA Regatta Plaza ETA 2013/08/16 09:11
CSO REVIEW Matthews, Darlene 2013/09/03 10:53
MOUNT PEARL, Mount Pearl ETA ETA 2013/09/06 12:28
CSO REVIEW Matthews, Darlene 2013/09/10 12:29
If something that is easier to maintain (for example, does not require the knowledge of regular expressions) is a priority, then write a PL/SQL function. Be able to use freeely vaiables and uses an IF-THEN-ELSE logic, will make it much easier to maintain.
Tags: Database
Similar Questions
-
Hello
IM needing help to cut a string like this... A, B, C, ADV, RAHEEM, MOUSTAFA, Gauthier,... compare letters he's be numbers, but I get by using a string... Need to divide and put each number into a vector, in all positions...
Can someone help me? ..
I'm using labview 6...
Here is the screenshot of my logic...
Hi faelnpaiva,
all you need is 'String of spreadsheet in table' with a ',' as the delimiter.
-
Need help pulling a name string
Hello I'm on Oracle 11 GR 1 material and have a strings of data like these:
SMITH, KAY C. RN, FNP
WESTON, DEBRA, L
ASH, CHRISTOPHER, J., PA - C
EYEBROWS, CATHERINE J MSN NOCD
ASH, MICHELLE
NASH, BOB MC T MD
BROWN-JONES, LARRY RN
I need to enter these:
LAST_NAME
FIRST NAME
MI
CODE (the first one)
So, if we where to watch again the data after it is pulled apart, I would like to see this:
That's what I have (this code will be executed on an external Table with 1.5mil lines):LAST_NAME FIRST_NAME MI CODE SMITH KAY C RN WESTTON DEBRA L ASH CHRISTOPHER J PA-C BROW CATHERINE J MSN ASH MICHELLE
I don't know how to get the rest.select substr('SMITH, KAY C. RN, FNP',1,instr('SMITH, KAY C. RN, FNP',',')-1) as LAST_NAME, regexp_substr(SMITH, KAY C. RN, FNP', '[^, ]+ ') as FIRST_NAME from dual;
Thanks for any help
Published by: Sky13 on September 23, 2011 12:04
I added a few samples moreHello
Look at the data and try to find some patterns. You will not be able to get everything right, but you may be able to make the most of them.
I would look for things:
There always at least 1 comma in the chain? Are you sure that what comes before the (first) comma is always a name?
When there are 2 commas, codes never come before the 2nd comma?
Codes always come after the names?
What parts are sometimes missing? How many times they lack?
Never just 1 character codes?
Some codes occur very frequently?
Is this practice to create a table of the most common codes, or even all the codes?It will be much easier in PL/SQL.
You can write a procedure which takes 1 IN argument (the plain text) and 5 on arguemnts:
(1) first name
(2) first name
(3) other initial
(4) code
(5) a number indicating what is the probability that the results are correct. For example, 100 may indicate a very simple string, such as "Dyer, Mary. You can print the with the lowest number for some person to review manually.Good luck!
-
Need help with SQL/PL/SQL for Dates
Hi Experts - need help with a SQL query.
I need to insert some date fields in a table called CALENDAR_PERIOD.
Current data in CALENDAR_PERIOD table with their data types:
STARTPERIOD (DATE) YEAR (NUMBER) PERIOD_LABEL (Varchar2 255)
02/11/2014 2014 2014/02/11 SUN
03/11/2014 2014 14/03/11 MON
04/11/2014 2014 11/04/14 MAR
I have to increment above values up to the year 2025. I don't know how to write SQL and increment of these values.
Ex: My next value should insert: 05/11/2015 2014 11/05/14 WED like that I need to insert data until 12 31, 2025.
Can you please help me with PL/SQL block?
Really appreciate your help!
DB version:
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE Production 11.2.0.3.0
AMT for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
Thank you
SandyHello Sandy,
Maybe something like
INSERT INTO calendar_period (startperiod, year, period_label)
SELECT DATE '' 2014-11-04 + LEVEL
, TO_NUMBER (TO_CHAR (DATE '' 2014-11-04 + LEVEL, "YYYY"))
, TO_CHAR (DATE '' 2014-11-04 + LEVEL, "MM/DD/YY DY")
OF the double
CONNECT BY LEVEL<= date="" '2025-12-314="" -="" date="">=>
;
((mais je ne comprends pas pourquoi nous créons une telle table "année" et "period_label" peuvent être calculé à partir de startperiod))
Best regards
Bruno Vroman.
-
Need help to parse the xml string to populate the drop-down list
Here is my: problem
I have a hidden text field that contains the text of an xml
<>facilities
< building >
< name > Building A < / name >
< name > building B < / name >
< name > building C < / name >
< name > building D < / name >
< name > building E < / name >
< name > building F < / name >
< name > building G < / name >
< name > building H < / name >
< / build >
< / facilities >My goal is to read this with JavaScript xml string to populate a drop-down list with values of element (name). Does anyone know how script that?
Attached is a sample .xdp
See you soon,.
Jesse
Here is an example of change. I put the code click on the button, so you can see it in operation... You can place this code in the event that makes sense for you. I also added another field to show the DOM (this is for debugging purposes and you can remove this field if you want).
Paul
-
Need help with a Citadel of DIAdem data store opening.
Hello
I was wondering if someone can help me to connect to a Citadel of DIAdem data store. I've read all the online help and cannot operate.
On my PC, I use DIAdem v11.1 and v6.1 Lookout installed as a plugin. I am trying to connect to a data of Citadel store 5 on a server visible in the image below, specifically the default database on HPSERVER1. The installation of MAX on HPSERVER1 tells me that there are 2 versions of LabVIEW Run-Time installed, 8.2.1 and 9.0.1 (I don't know if this is relevant).
When I select \\hpserver1\default_database, I then set the properties as follows:
In the Advanced section, I'm the deadline set to 90 seconds. When I hit OK, then I get the following message, which then brings back me to the previous screen.
Any help is very appreciated,
David.
Hi David,
6.2 Lookout CLIENT is for people who do not have installed Lookout but still want to connect to a database of Citadel with DIAdem. This works for databases Citadel created by Lookout as long as those created by LabVIEW DCS, is said by the way.
In your case, you have already installed Lookout, you don't need this additional client software. There is no improvement in functionality in this interface between 6.1 and 6.2, so you do not miss anything, and youre data import is already working.
I don't know about lookout not appearing is not in the License Manager, etc. I'm sorry.
Brad Turpin
Tiara Product Support Engineer
National Instruments
-
Need help saving the computer to paste data in Vista
I want to back up my computer to a data key. I followed the instructions until I got to the bit where I need to plug in the stick and two ports, it came on J: /. How to locate the E: / drive?
Thank you.
Carol
* original title - E: / drive - how can I find? *
If the stick is confirmed as J:\ disc, why you need it to be drive E:\? Just use the drive letter assigned to it and you'll be fine.
If you want to know about drive E:\ (whatever it is), and then click Start / Contol Panel / administrative tools / computer management / disk management and search for E:\ drive. If she's not here, I don't know how to explain why the system has assigned drive J:\ to the key, but it makes no real difference he'll change from computer to computer depending on what is installed (but it willl always be able to access).
I hope this helps.
Good luck!
Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.
-
Hello
I have the string as Wednessday, June 13, 2009 | 12 AM GMT, I want to analyze and convert data type Date. I did the same on J2SE, but class SimpleDateFormat does not parse method in RIM API.
Please suggest.
Thank you
RJ
If you are looking for an answer on how to do it in Java, you're the best post your question in the Java development forums.
-
Need help for the conversion of the Date
Hi all
Your expert input is much appreciated.
Have a problem where it is my master table structure, whenever there is an update/delete/insert on the main table
There's a trigger that insert an entry in the Audit table.
SQL > cpp_Master Desc;
Number of Ent_id
Date of Ent_date
SQL > Desc Cpp_Master_Audit
Number of Ent_id
Date of Ent_date,
Insert_type varchar2 (1)
The problem is that when we insert the Sub record in the table, the ent_date column appears in this way.
SQL > INSERT INTO CED.cpp_Master (ENT_ID, Ent_date)
VALUES (6030902, TO_DATE (1 JANUARY 01 00:00:00 ', ' HH24: PUT DD/MM/YYYY "));SQL > SELECT * FROM CED.cpp_Master;
6030902 01/01/0001
SQL > SELECT * FROM CDS. Cpp_Master_Audit;
6030902 01/01/0001
But when I update the date is coming up as below
SQL > update ced.cpp_Master set Ent_date = to_date (' 1 March 01', ' dd-mon-YYYY "") where ent_id = '6030902';
SQL > commit;Tried under updates so
(
Update ced.cpp_Master set Ent_date = ' March 1 01' where ent_id = '6030902';
Update ced.cpp_Master set Ent_date = to_char (' 1 March 01', ' dd-mon-YYYY "") where ent_id = '6030902';
)
Whenever the output below always. (Insert has no problem, just update a problem)
I wonder why when there is an insertion of the date value is "01/01/01" in (Cpp_Master_Audit), but when I update the date value is "01/01/2001" ".
I need the value to insert as "01/01/01", as all that was updated in Master table (Cpp_Master)
SQL > SELECT * FROM CED.cpp_Master;
6030902 01/01/2001
My request to trigger:
CREATE OR REPLACE TRIGGER CDS. CPP_AUDT
AFTER INSERT OR UPDATE OR DELETE
ON CED.cpp_Master REFERENCING OLD AS OLD AGAIN AS NEW
FOR EACH LINE
DECLARE
l_action_code VARCHAR2 (1);
BEGINIF THE INSERTION
THEN
l_action_code: = 'I ';
ELSIF UPDATE
THEN
l_action_code: = 'U ';
ON THE OTHER
l_action_code: = ';
END IF;IF (l_action_code = 'I'
OR l_action_code = '
OR (l_action_code = 'U'
AND (NVL (: OLD.)) ENT_ID, 0) NVL <>(: NEW.) ENT_ID, 0)
OR NVL (TO_CHAR (: OLD.)) Ent_date, ' mm/dd/yyyy'),
'X') <>
NVL (TO_CHAR (: NEW.)) Ent_date, ' mm/dd/yyyy'),
« X »)
)))
THEN
INSERT IN DEC. () Cpp_Master_Audit
ENT_ID, Ent_date, Insert_type
)
VALUES (DECODE (: OLD.ent_id, NULL,: NEW.ent_id,: OLD.ent_id),)
DECODE (l_action_code, 'I',: NEW.) Ent_date, 'd', NULL, 'U', DECODE (: NEW.) Ent_date,: OLD. Ent_date, NULL,: NEW. Ent_date)),
Insert_type l_action_code);END IF;
END;
/You wrote that ent_date is of type DATE
SQL > cpp_Master Desc;
Number of Ent_id
Date of Ent_date
so DO NOT fill with a chain, but with a date, and you have correct data in it.
This:
Update ced.cpp_Master set Ent_date = 1 March 01 ' where ent_id = '6030902';
is simply wrong that fill you your column DATE with a string and your NUMBER column with a string filter too.
Use
Update ced.cpp_Master
Set Ent_date = TO_DATE('01-MAR-0001','DD-MON-YYYY') where ent_id = 6030902;
and you will have no problems (as long as the NLS_DATE_LANGUAGE parameter is set correctly to support abbreviations English months)
HTH
-
Need help with the code to add dates to form
Hello fans forum
I am new to make forms and understood how to auto add the date, but I need the shape to change the date for each copy made.
For example, is today 08/06/2012 if I print 10 copies of the form it will display 10 pages from 08/06/2012 to 17/06/2012. If the code exists for this I would be very gratefull to one who helps, I also wouldn't mind if this is not possible for manually inputing start / end dates.
Currently I have print 15-30 copies of the form and hand write each of the dates but I get just to busy to do it. Also I can't print one a day, it must be in batches.
Thanks in advance.
I think that you misunderstood my comment about the Console window. Please see the Console window tutorial link in my previous answer. The Acrobat JavaScript Console window is internal to Acrobat, so there is no system restrictions that may prevent you from using it. It's a perfect place to run short automation scripts that do things like print separate copies.
George also underscores a great solution, put the script in a (non-printable) button on the document itself. However, due to security restrictions this solution can be a bit tricky, but no more so than using the Console window. Each solution takes a little extra effort.
The problem with having multiple pages, it's that you must manually create a document with pages already in it. It is certainly a feasible solution, it comes you limit the number of pages that you have already created manually. At least one solution AcroForm. If you re-create your form as a dynamic LiveCycle, then creating new pages on the fly is not a problem.
None of these solutions will work fine, the real trick is to increment the date.
Here's a short script that begins with today's date and adds a day for each iteration of the loop and then prints
One day in milliseconds
var nOneDay = 24 * 60 * 60 * 1000;
var nToday = (new Date()) .getTime ();
for (var i = 0; i)<>
{
oTheDate = new Date (nToday + i * nOneDay);
Date format
cTheDate = util.printd("mm/dd/yyyy",oTheDate);
this.getField("MyDate").value = cTheDate;
This.Print)
}
This same loop could be used to fill in a form on the page - multi (repeated) fields.
Using the util.scand () function, this loop could be setup to start at an arbitrary date.
See you soon,.
-
[Help] Need help to remove a string in the text file
Hi all
I have a text like this
REPORT
Wednesday, June 10, 2015 14:31:56
**********************************************************************************
HOST: 10.9.1.185
TestVM is turned off
**********************************************************************************
HOST: 10.9.0.84
All virtual machines are turned off
**********************************************************************************
HOST: 10.9.0.85
**********************************************************************************
HOST: 10.9.0.86
I want to remove the
**********************************************************************************
HOST: 10.9.0.85
**********************************************************************************
HOST: 10.9.0.86
because there is no information after the HOST 10.9.0.85 or: 10.9.0.86
It will reduce the content of the report
I need a script to delete this text
Could someone help me?
Thank you for your help
What generates the report? It is probably easier to just do not write to the file in the first place...
-
Need help to try to "include vector data" when you save an EPS? Anyone?
Although I've done several times before, I just can't understand why the checkbox "include vector data" is grayed out. I work in CMYK mode - I placed my business as a smart object as usual - logo and none of my layers have applied effects. Scratching my head right now. It is a format large poster so I will certainly need to fix this somehow. Any guidance would be greatly appreciated.
You must have a layer with a vector mask applied to the function is displayed.
-
Need help with the query string manipulation
Hello
With the help of 10.1.0.4.2
Given a table called PREFIX_CODES that contains a column called PREFIX_CODE
with the following data:
PREFIX_CODE - VARCHAR2 (20)
-------------------
AAA
BENAMER
CARTER
and another table called SUBSCRIBERS with a column called SUBSCRIBER_ID
with the following data:
SUBSCRIBER_ID - VARCHAR2 (30)
---------------------
BBBB-123456
AAA-444444
DD-2222222
EEEE-888888
Is there a query that will pull all the SUBSCRIBER_ID that begin with
each of the PREFIX_CODES? The following query is not valid, but it
This will give you an idea of what I'm trying to do:
SELECT SUBSCRIBER_ID
SUBSCRIBERS
WHERE AS SUBSCRIBER_ID (SELECT PREFIX_CODE |) » %'
OF PREFIX_CODES)
Using the data from above, I would like that the query to return:
BBBB-123456
AAA-444444
Thanks for your help!Hello
Welcome to the forum!
You were on the right track. To find if a given subscriber corresponds to any prefix_code, you can do an EXISTS subquery:
SELECT subscriber_id FROM subsribers s WHERE EXISTS ( SELECT NULL FROM prefix_codes WHERE s.subscriber_id LIKE prefix_code || '%' ) ;
This will tell you if at least a prefix code. It won't tell you exactly how many, or what they were.
Your message, I'm guessing that there may be more than one, and you can deduct the subscriber_id itself, then the above query should work for you. -
Need help to split the string into two fields
Can someone share your thoughts by dividing the prod_info string below into two fields
For example:-TABLE of PROD
SOURCE TABLE
SNO PROD_INFO 1 20 OZ SIMILAC 2 HW PRO 10 3 REX 10 OZ 4 AAA 10 5 BBB 2000 6 CCC 10 LB 7 DDD 2021 8 EE 12 KG 9 KK 11111 10 ZZ ABC FAC 11 11 RKW DD CC 12 OZ 12 12KJ 12 LBS. EXPECTED RESULTS
SNO PROD_INFO PROD_VAL 1 SIMILAC 20 OZ 2 HW PDR 10 3 REX 10 OZ 4 AAA 10 5 BBB 2000 6 CCC 10 LB 7 DDD 2021 8 EA 12 KG 9 KK 11111 10 AEC ABC ZZ 11 11 RKW DD CC 12 OZ 12 12KJ 12 LBS. with
as Prod
(select 1 sno, "SIMILAC 20 OZ" prod_info of all the double union)
Select 2, 'HW PDR 10' from dual union all
Select 3, 'REX 10 OZ' from dual union all
Select option 4, "AAA 10' from dual union all
Select 5, "BBB 2000"of the dual union all
Select 6, 'CCC 10 LBS' double union all
Select 7, 'DDD 2021' from dual union all
Select 8, 'EE 12 KG' from dual union all
Select 9, 'KK 11111' Union double all the
choose 10, "ZZ ABC FAC 11' from dual union all
Select 11, 'CC DD RKW 12 OZ' from dual union all
Order 12, '12KJ LB 12' double
)
Select sno,
(prod_info regexp_substr(prod_info,'^((\d*|\w*)[^[:digit:]].*) \d',1,1,null,1).
regexp_substr (prod_info,' prod_value (\d+.*)$',1,1,null,1))
Prod
SNO PROD_INFO PROD_VALUE 1 SIMILAC 20 OZ 2 HW PDR 10 3 REX 10 OZ 4 AAA 10 5 BBB 2000 6 CCC 10 LB 7 DDD 2021 8 EA 12 KG 9 KK 11111 10 AEC ABC ZZ 11 11 RKW DD CC 12 OZ 12 12KJ 12 LBS. Concerning
Etbin
-
Need help with debugging case manipulation statement &; date
Hi people,
Can you get it someone please let me know what I am doing wrong?
Select to_date (23-seven.-10', 'DD-MON-yy') expiry_date,.
TO_DATE (23-sep-09', 'DD-MON-yy') order_date,.
TO_DATE (23-seven.-10', 'DD-MON-yy')-to_date (23-sep-09', 'DD-MON-yy') diff,.
(case diff
When < 365 then 'low '.
When > 365 then 'high '.
other 'similar '.
end)
Double;
ORA-00936: lack of expression
00936 00000 - "missing expression.
* Cause:
* Action:
Error on line: column 5:18
Thanks in advance
rogers42Here you go
WITH temp_tab AS (SELECT to_date('23-sep-09', 'DD-MON-yy') order_date, to_date('23-sep-10', 'DD-MON-yy') -to_date('23-sep-09', 'DD-MON-yy') diff, to_date('23-sep-10', 'DD-MON-yy') expiry_date FROM dual) SELECT( CASE WHEN diff < 365 THEN 'low' WHEN diff > 365 THEN 'high' ELSE 'same' END) FROM temp_tab;
Maybe you are looking for
-
Satellite R630-13R - cannot update the BIOS
Hello I downloaded a bios file for my ticket from the TOSHIBA support center but could not be updated. The message says "this computer is not supported", but I don't know I downloaded the right file. Could you please help me?Thank you!
-
may charged iPhone wi - fi?
Can iPhone 5s be invoiced wi - fi
-
I'm trying to implement password policy in Windows XP Home Edition. I want the password to expire in 90 days. I followed the instructions in this article by using a Windows XP Home Edition. I used the command 'net accounts' before and after the ste
-
Why my router Linksys changed the password?
I have a WRT610N router. Earlier today, I had to stop the power on everything. When I brought it up, it seems that he has changed the SSID that it broadcasts to the 2.6 version and the 5 GHz band. Why he did it?
-
backup Windows 0 x 80070002 that the system cannot find the specified file
I have a new laptop with Windows 7 and receive the error in the title when you run the backup. I looked at the two http://support.microsoft.com/kb/979281 and http://support.microsoft.com/kb/976972 The laptop doesn't have a Nvidia chipset and has suff