?
Solved

Extract the first word (before the , )

Posted on 2016-11-29
2
Medium Priority
?
76 Views
Last Modified: 2016-11-29
Hi All,

I need to extract from a list below only the first word. Data is a little tricky, in few lines, there is no space after the first comma. Using Oracle 11g.

BOLT, ELEVATOR: 5/16", 2"LG, UNC, BLACK, 100
CAPSCREW, SOCKET HEAD: 10-32, 3/8"LG, 8, FLAT, PKG QTY = 100
CAPSCREW, SOCKET HEAD: 10-32, 1"LG, PLATED, 8, FLAT, 100
CAPSCREW,SOCKET HEAD: 1/4", 28, 1/2"LG, PLATED, 8, FLAT, 100
CAPSCREW,FLAT SOCKET HEAD:1/4"-28, 3/4"LG, GR8,COUNTERSUNK, PKG QTY = 100
SCREW,SHEET METAL: #10 X 3/8", PLATED, BINDING, ROBERTSON, GIMLET POINT, PKG QT

Thanks
0
Comment
Question by:mohammadzahid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 41906604
Try regular expression

Regexp_substr(line, '\w[^,]', 1, 1)
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 41906605
Try this:
select regexp_substr(some_column,'^[^,]*') from some_table;
or
select substr(some_column,1,instr(some_column,',')-1) from some_table;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question