Extract the string from the string

Hello guys,.

I have a small question. I would like to extract a string to another string. Imagine the following string:

param1 = value1 param2 = value2, param3 = value3, param4 = value4

I would like to be able to extract value2 and value3 to this string. I know that the design of the db is not perfect and should be like this. but it is historical and I have to use this way. Any suggestion?

Thank you

to retrieve param2

Select

substr (s

, instr (s, '=', 1, 2) + 1

, instr (s, ',', 1, 2) - instr (s, '=', 1, 2) - 1

) r

from (select "param1 = value1 param2 = value2, param3 = value3, param4 = value4's double)

or

Select regexp_substr (your_string, "[^,] +' 1, 4") from your_table

for example

Select regexp_substr ("param1 = value1 param2 = value2, param3 = value3, param4 = value4 ',' [^,] +' 1, 4") param2 double

PARAM2

'value2 '.

Post edited by: chris227
Corrected solution substr (sorry was before the first coffee ;-))

Tags: Database

Similar Questions

  • Extract the string from the chain - separator = ' | '?

    Hi people!

    I want to know how to extract the a string with delimiter = XE field ' |'.

    For example:
    String = "field1 |" Field2 |... | fieldX |... | filedn | »

    I want to extract fieldX.

    Thanks for your help, regards.

    Use the functions like this substr and instr

    substr(string, instr( string,'|', 1, xth_occurrence)+1, instr( string,'|', 1,xth_occurrence+1) - instr(string,'|', 1, xth_occurrence))
    

    Luca

    Please, mark the reply as useful/correct if it is

    Published by: Luka on January 26, 2010 10:42

    Published by: Luka on January 26, 2010 10:42

  • I'm trying to extract the strings and load them into a text-helpplease file

    I'm trying to extract the strings and load them into a file text without space between them - see below

    p_csa = ISCC M4 DP

    where p_csa is a tring to load into a text file



    Code:

    SELECT SUBSTR (p_csa, 0, 0) INTO v_telco FROM DUAL;
    SELECT SUBSTR (p_csa, 1, 4) INTO v_comp FROM DUAL;
    SELECT SUBSTR (p_csa, 5.3) INTO v_csa_prefix FROM DUAL;
    SELECT SUBSTR (p_csa, 8, 4) INTO v_csa_type FROM DUAL;

    fileidinvoice: = UTL_FILE. FOPEN (c_data_location, filenameinvoice, 'W');
    fileidlog: = UTL_FILE. FOPEN (c_data_location, filenamelog, 'W');

    UTL_FILE. PUT_LINE)
    fileidinvoice, v_telco | » '|| v_comp | "|" | v_csa_prefix: "| v_csa_type);


    -the content of the file-

    ISCC M4 DP

    =====================
    I want to remove the space between the chain above for the content of the file should look like this:

    -the content of the file-

    GCSIM4DP

    Hello

    976253 wrote:
    I'm trying to extract the strings and load them into a file text without space between them - see below

    p_csa = ISCC M4 DP

    where p_csa is a tring to load into a text file

    Code:

    SELECT SUBSTR (p_csa, 0, 0) INTO v_telco FROM DUAL;

    Is it always NULL?

    SELECT SUBSTR (p_csa, 1, 4) INTO v_comp FROM DUAL;

    You don't need the double table much in PL/SQL. You can simply say

    v_comp := SUBSTR (p_csa, 1, 4);
    

    Almost all integrated single-row functions work in PL/SQL. (NVL2 is the only one I know who does not work in PL/SQL).

    SELECT SUBSTR (p_csa, 5.3) INTO v_csa_prefix FROM DUAL;
    SELECT SUBSTR (p_csa, 8, 4) INTO v_csa_type FROM DUAL;

    fileidinvoice: = UTL_FILE. FOPEN (c_data_location, filenameinvoice, 'W');
    fileidlog: = UTL_FILE. FOPEN (c_data_location, filenamelog, 'W');

    UTL_FILE. PUT_LINE)
    fileidinvoice, v_telco | » '|| v_comp | "|" | v_csa_prefix: "| v_csa_type);

    What are you trying to do here? For example, what you're trying to put between c_comp and v_csa_prefix?

    -the content of the file-

    ISCC M4 DP

    =====================
    I want to remove the space between the chain above for the content of the file should look like this:

    -the content of the file-

    GCSIM4DP

    If you don't want space, then only concatenate all the spaces in the string before you write it and REPLACE allows you to delete all the spaces that have been copied from p_csa. For example:

    UTL_FILE.PUT_LINE ( fileidinvoice
                , REPLACE ( v_telco || v_comp
                                        || v_csa_prefix
                              || v_csa_type
                       , ' '
                       )
                );
    

    I guess you need the v_comp of separate variables, the v_csa_prefix and the v_csa_type for something.

    I hope that answers your question.
    If this isn't the case, after a complete script that people can run to recreate the problem and test their ideas. Display the results you want (in other words, the contents of the file created).
    Always say what version of Oracle you are using (for example, 11.2.0.3.0).
    See the FAQ forum {message identifier: = 9360002}

  • Analyzes the string and extract the string delimiter

    Hello

    Basic questions.  Is this possible with the scan of regular expression of the string to extract the string that are in the specified delimiters.  Here is an example:

    Name of the \\Name of the folder 1\Name to the folder 2\Name to the folder 3\File

    Chain analysis can produce the following by specifying the regular expression on the right:

    1 folder name

    Name of the folder 2

    Name of the folder 3

    File name

    I tried \\\%s\\%s\\%s\\%s but the %s stops on the first white space.

    Thank you

    Michel

    RavensFan suggested the service appropriate for your condition, but you can also use an alternative, which is "spreadsheet of array of strings.

  • Extract the contents of an XML string in offline mode

    HI gentlemen,

    Could you help me solve this problem? I had a string of Java (see below) read in a smart German eHealth card. I have to extract the tag values and put them in local variables for further processing in my Java module. How to move forward without connecting to a database, it is enough to analyze the source - the string variable? Note that the lines are separated by only 0x0A.
    <?xml version="1.0" encoding="ISO-8859-15" standalone="yes"?>
    <UC_PersoenlicheVersichertendatenXML CDM_VERSION="5.1.0" xmlns="http://ws.gematik.de/fa/vsds/UC_PersoenlicheVersichertendatenXML/v5.1">
        <Versicherter>
            <Versicherten_ID>X110101627</Versicherten_ID>
            <Person>
                <Geburtsdatum>19840717</Geburtsdatum>
                <Vorname>Johanna</Vorname>
                <Nachname>Düsterbehn</Nachname>
                <Geschlecht>W</Geschlecht>
                <StrassenAdresse>
                    <Postleitzahl>93055</Postleitzahl>
                    <Ort>Regensburg</Ort>
                    <Land>
                        <Wohnsitzlaendercode>D</Wohnsitzlaendercode>
                    </Land>
                    <Strasse>Sulzfeldstraße</Strasse>
                    <Hausnummer>7</Hausnummer>
                </StrassenAdresse>
            </Person>
        </Versicherter>
    </UC_PersoenlicheVersichertendatenXML>
    Thank you very much for your help,
    sincere friendships of

    Miklós HERBOLY
    java.lang.NoClassDefFoundError: XpathSampleClass (wrong name: XPathSampleClass)
    

    If you use my code sample in extenso, the class is named 'XPathSampleClass' (capital P), and of course the .class file must have the same name.

  • Extract the first name and last names of a string

    Hello people,
    I am trying to extract the last name, first name, first name and initial of some names of students for a report. I have some success with the first name and the first names, but have some difficulty to come with the other two. I use Oracle 9i and would like to come with the SQL.

    Script to create the table:
    create table grad_student_tb
    (student_id varchar2(3) primary key,
     salutation varchar2(4),
     student_name   varchar2(60));
    Script to insert records into the table:
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('001','Mr','Adams,Robert Murphy');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('002','Mr','Green,Eric Craig');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('003','Miss','Brown,Jennifer William H');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('004','Mr','Adams,Michael William H');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('005','Miss','White,Snow');
    Here's what I would like on my report:
    Student ID   First Middle Name    Last Name   First Name   Initial
    ==================================================================
    001          Robert Murphy        Adams       Robert       M
    002          Eric Craig           Green       Eric         C
    003          Jennifer William H   Brown       Jennifer     W
    004          Michael William H    Adams       Michael      W
    005          Snow                 White       Snow
    Currently my SQL looks like this:
    select student_id,
           SUBSTR(student_name, INSTR(student_name,',')+1, LENGTH(student_name)) first_middle_name,
           SUBSTR(student_name,1, INSTR(student_name,',')-1) last_name
    from   grad_student_tb;
    Output:
    STUDENT_ID FIRST_MIDDLE_NAME                                            LAST_NAME                                                    
    ---------- ------------------------------------------------------------ ------------------------------------------------------------ 
    001        Robert Murphy                                                Adams                                                        
    002        Eric Craig                                                   Green                                                        
    003        Jennifer William H                                           Brown                                                        
    I need to come up with the first name and initial of the students.

    Any help is greatly appreciated!

    Thank you

    Published by: Roxyrollers on August 18, 2011 12:53

    Assuming that each name is exactly the same format

    SQL> ed
    Wrote file afiedt.buf
    
      1  select student_id,
      2         SUBSTR(student_name,
      3                INSTR(student_name,',')+1,
      4                LENGTH(student_name)-INSTR(student_name,' ')) first_name,
      5         SUBSTR(student_name,
      6                INSTR(student_name,' ')+1) middle_name,
      7         SUBSTR(student_name,
      8                INSTR(student_name,' ')+1,
      9                1) middle_initial,
     10         SUBSTR(student_name,1, INSTR(student_name,',')-1) last_name
     11* from   grad_student_tb
    SQL> /
    
    STU FIRST_NAME      MIDDLE_NAME          MIDDL LAST_NAME
    --- --------------- -------------------- ----- ---------------
    001 Robert          Murphy               M     Adams
    002 Eric            Craig                C     Green
    003 Jennifer        William H            W     Brown
    

    In general, of course, analysis names as it is much more complicated because you have to deal with the family as "la Hoya" names that contain spaces and cannot easily be distinguished from someone with several names.

    Justin

  • Extracting the data from QVariantMap

    I have the following data :

    QVariant (QVariantMap, QMap ((' data', QVariant (QVariantMap, QMap ((' current_condition', QVariant (QVariantList, ((QVariantMap, QMap... QVariant QVariant (QVariantMap, QMap ((' weather', QVariant (QVariantList, ((QVariantMap, QMap... QVariant QVariant (QVariantMap, QMap ((' weather_desc', QVariant (QVariantList, ((QVariantMap, QMap... QVariant

    m_model-> insert(data.value() .value ("data") .toMap ().value("weather").toList () .at (0) .toMap ());

    Using the above line, I am able to extract relevant data from "current_condition and"weather".

    What should I add to the line above to also extract data from 'weather_desc '?

    Any help would be appreciated. Thank you.

    Thank you! It is much easier to read when formatted, it's the first thing I did.

    { "data":
      {
        "current_condition":
        [
          {
            "cloudcover": "0",
            "humidity": "18",
            "observation_time": "02:36 AM",
            "precipMM": "0.0",
            "pressure": "1007",
            "temp_C": "39",
            "temp_F": "102",
            "visibility": "10",
            "weatherCode": "113",
            "weatherDesc": [ {"value": "Sunny" } ],
            "weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ],
            "winddir16Point": "N",
            "winddirDegree": "10",
            "windspeedKmph": "46",
            "windspeedMiles": "29"
          }
        ],
        "request":
        [
          {
            "query": "Melbourne, Australia",
            "type": "City"
          }
        ],
        "weather":
        [
          {
            "date": "2013-01-04",
            "precipMM": "0.0",
            "tempMaxC": "37",
            "tempMaxF": "98",
            "tempMinC": "19",
            "tempMinF": "66",
            "weatherCode": "113",
            "weatherDesc": [ {"value": "Sunny" } ],
            "weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ],
            "winddir16Point": "N",
            "winddirDegree": "3",
            "winddirection": "N",
            "windspeedKmph": "21",
            "windspeedMiles": "13"
          }
        ]
      }
    }
    

    To access weatherDesc in usage by time:

    Data.value.value("data").toMap ().value("weather").toList () .at (0) .toMap ().value("weatherDesc").toList () .at (0) .toMap .value ("value") ())

    This will return "Sunny."

    For readability, I suggest if this string to:

    QMap  dataMap = data.value().value("data").toMap();
    
    QList weatherList = dataMap..value("weather").toList();
    
    QVariant firstWeatherEntry = weatherList.at(0);
    
    QMap weatherEntryMap = firstWeatherEntry.toMap();
    
    QList weatherDescList =
    weatherEntryMap.value("weatherDesc").toList();
    
    QVariant firstWeatherDescEntry = weatherDescList.at(0);
    
    QMap weatherDescEntryMap = firstWeatherDescEntry.toMap();
    
    QString value = weatherDescEntryMap.value("value").toString(); // "Sunny"
    

    Also, you can check intermediate outcomes at each stage by calling

    qDebug()< weatherlist="">< "\n";="" and="" so="">

  • Use regular expressions to extract .llb file from the path name

    I'm trying to be smart (always a dangerous thing) and use a regular expression to extract the name of a library to a filepath converted to a string.   While I appreciate there are other ways to do this, regex seems to be a very powerful way of neat, I would be able to operate.

    IE, if I have a string of type, C:\applications\versions\library.llb\toplevel.vi, I want to be able to extract the library.llb of the string, because it will be of variable length, may include the numbers & spaces and may be located in a file of variable depth hierarchy.   In other words, I want to extract the part of the string between the last-which ends with .llb

    The best I managed so far is \\+.*llb who all returned less the drive letter and the toplevel.vi

    Can someone help me to achieve this goal, or I'm better by using an alternative method (for example filepath string in array, search for .llb)

    Thank you

    Matt

    Hi Matt,

    attached you will find two other options.

    Mike

  • How to extract the files from the HARD drive?

    I have a HDD1805 from a broken iPod 80 GB. I was wondering if there was another method I could use to extract the files from the hard drive.

    Hello

    Sorry, but I don t know what you mean exactly.
    Can you please explain exactly what you mean?

    What files you want to extract?

    Good bye

  • No luck trying to extract the .inf files from the drivers downloaded as zip files

    Hello

    I try to extract the .inf files from the drivers downloaded as files zip on the Toshiba site, but I'm having no luck.

    I'm trying to deploy images by using WDS on Server 2008 and need inf files if it is to succeed, there the answer to this problem.

    Thanks in advance.

    Hello

    I can unpack any driver package downloaded from the Toshiba driver page.
    I use the free tool called WinRAR.

    Maybe it helps you

  • DV7 - 7333cl: how to extract usable data from a bad drive using 22 pins adapter usb to SATA on the new HD

    Greetings HP Forum,

    Recently, I replaced a bad hard drive on my laptop. I need now step by step procedure to extract usable data from the wrong drive using 22 pins adapter usb to SATA on the new HD.

    NOTE: I can't not all data that especially if some of the software downloaded on the replaced disk can be altered. Should I first download Internet Antivirus to protect my new hard drive? I'm not an expert, or even close to this when you work on the back of the laptop, so I'll have to step by step how to download and to partition the data recoverable and software, etc..

    Thanks in advance for your help... I greatly appreciate it!

    See you soon!

    Wes

    It is not complex. Attach the drive to the adapter and connect it to any other computer with good antivirus and antispyware installed. I use Malwarebytes and Avast. When you connect the adapter with the drive connected to the usb port, the drive will appear and it will be assigned a letter maybe E:\ or F:\ or something else. Immediately, he analyzes with the antivirus and anti-spyware. Quarantine or delete any virus or malware it finds. Then, it's just a matter of navigate the disk and copy and paste the contents of the host computer in a directory for this purpose. Obviously, you can copy from documents word, photos, music files, but you cannot copy the applications like Microsoft Word, iTunes. Photoshop.  You may need to take ownership of the files on the old hard drive, but Windows will guide you through this. Don't know what else I can answer.

  • I accidentally deleted a file from my USB. is it possible to extract the file?

    original title: the files on USB.

    I accidentally deleted a file from my USB. is it possible to extract the file?

    Try using one of the many recovery tools. R-Studio is good, but the ins' free t. Microsoft Student Partner

  • Extract the Variables from Script Powershell

    Hey guys

    I am building a workflow active directory of this synchronization for the IAC database and I'm looking to make the most effective possible by reducing the amount of powershell scripts I use one only and then use the variables powershell to get what I need.

    Is it possible to extract the variables stored in a variable of workflow instead of use the output of the powershell statement?

    Has anyone built a workflow to users of this synchronization of DB works maximum efficiency on the when modified date now that mine is 28 minutes to synchronize 200 users.

    Matt

    From a design point of view, I would say to use the generic OLEDB data adapter.  There is an OleDB for Active Directory Provider called ADsDSOObject. You can find it by searching on the Microsoft site.  It can be installed as part of the standard Windows or .net.  I'm not sure. If you could get it saved on the server of PO, you would be able to do a select and use the output as native table instead of the Powershell output analysis.

    PowerShell has a tendency to be underperforming.  Certainly, I'd caution against the appellant PowerShell repeatedly in a loop.

  • Hi, after all stages of extraction of data from oracle to oracle during the execution of command "start extract ext1" his error giving the Manager does not work, can you please help me. Thank you

    Hi, after all stages of extraction of data from oracle to oracle during the execution of command "start extract ext1" his error giving this handler does not run both source and target, can you please help me. Thank you

    Hello

    The setting should be as below, and not only the port number should be...

    PORT 7809

    Kind regards

    Veera

  • Extraction of data from the xmlclob attribute

    Hi all

    I am trying to extract the value of the attribute below clob.

    kindly advice how to retrieve the value by using the xml functions.

    I use version 11.2.0 and toad 9 oracle database.

    I've highlighted the comment tag. the highlighted, I need to recover ' time changed according to the dtd VSG mail 25/01/2013 14:27.» SVK, & #xD; & #xA; Recipient added by mail from Richard dtd 20/02/2013 09:45. SVK" of the value attribute.

    Please suggest how to achieve using SQL. Data stored in xml format in the clob column.



    <? XML version = "1.0"? >

    " < ValuationRequest xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance "container =" " http://www.w3.org/2001/XMLSchema "ValueID ="169821"Version ="2.6" "

    " xmlns =" http://XBank.FxVals/ProcessValuationRequest.xsd "Status ="AC"> "

    < ValueID '5' = ClientRelationShipType > < / ClientRelationShipType >

    < ValueID owner = '14539"Name ="JEREMY LEVINE"> < / owner >

    < ValueID customer = "6892067" Name = "XXXXXXXXXX, NEW YORK" > < / customer >

    < ValueID = "1" CMVRegion > < / CMVRegion >

    < ValueID = "1" ValuationTypeID > < / ValuationTypeID >

    < CSRContacts >

    < CSRContact Value = "917" Name = "EVALUATIONS NY[valuations.ny@gmail... com]' > < / CSRContact >

    < / CSRContacts >

    < title >

    < ValueID security = PrimaryID "900158" = "NY-518362" ItemLevel = '2' ItemType = "38" >

    "< rank EffectiveDate =" "2013-01 - 24 T 00: 00:00 ' TerminationDate = ' 0001-01 - 01 T 00: 00:00" comments = "" SecurityDetailID = "429190" > < / row >

    < / security >

    < ValueID security = PrimaryID "900158" = "NY-518362" ItemLevel = '1' ItemType = "38" >

    "< rank EffectiveDate =" "2013-01 - 24 T 00: 00:00 ' TerminationDate = ' 0001-01 - 01 T 00: 00:00" comments = "" SecurityDetailID = "429191" > < / row >

    < / security >

    < / securities >

    < created Value = "2013-01 - 24 T 12: 20:48" > < / creation >

    < ValueID '37126' = CreatedBy > < / CreatedBy >

    < LastModified Value = "2013-02 - 21 T 01: 56:00" > < / LastModified >

    < ValueID = '18732' LastModifiedBy > < / LastModifiedBy >

    < ReportDefinition ValueID = "1" > < / ReportDefinition >

    < StartDate = value "2013-01 - 24 T 12: 00:00" > < / StartDate >

    <Comment Value = "time changed according to the dtd VSG mail 25/01/2013 14:27." SVK, & #xD; & #xA; Recipient added by mail from Richard dtd 20/02/2013 09:45. SVK">< / comment >

    < ValueID = "100" PricePercentage > < / PricePercentage >

    < ISDSL Value = "F" > < / ISDSL >

    < ValueID effects = '0' > < / Effects >

    < WorkFlowAction >

    ActiveChangesApproved < action > < / Action >

    < / WorkFlowAction >

    < ValueID = "4" RecertificationFrequency > < / RecertificationFrequency >

    < RecertificationDate Value = "0001-01 - 01 T 00: 00:00" > < / RecertificationDate > "".

    < RecertificationNextDate Value = 'January 24, 2014' > < / RecertificationNextDate >

    < StatementFrequency >

    < SFrequency Value = '1' Type = 'Daily' date limit indicator = "1005" = "F" PDeadline = '990' > < / SFrequency > "

    < / StatementFrequency >

    < value AutoGenerate = "T" > < / AutoGenerate >

    < monetary value = "Us $" > < / currency >

    < SLanguage ValueID = "1" > < / SLanguage >

    < GP2AccountID Value = "480352" > < / GP2AccountID >

    < SalesApproval Value = "F" > < / SalesApproval >

    < RegenerateAfterPartial Value = "F" > < / RegenerateAfterPartial >

    < SalesCoverageTeam >

    < = 'Sales' sales type Value = "14539" NotificationFlag = "N" name ="JEREMY LEVINE [[email protected]]" > < / sales > "

    < / SalesCoverageTeam >

    < OffSystem Value = "F" > < / OffSystem >

    < HolidayCalendar >

    < country value = 'US' > < / country >

    < / HolidayCalendar >

    < GP2AccountStatus Value = "P" > < / GP2AccountStatus >

    < CurrencySecondary / >

    < GP2ParentID Value = '16649' > < / GP2ParentID >

    < StatementPerspective Value = "D" > < / StatementPerspective >

    < DBEntity ValueID = "2" > < / DBEntity >

    < ValueID DisplayClientName = "6892067" Name = "XXXXXXX, NEW YORK" > < / DisplayClientName >

    < FXRates >

    < FXRate >

    < of Value = "EUR" > < / From >

    < value = "Us $" > < /pour >

    < / FXRate >

    < / FXRates >

    < ShowFXRates Value = "T" > < / ShowFXRates >

    < OfficialMTMs Value = "F" > < / OfficialMTMs >

    < ExcludeStructuredTrades Value = "F" > < / ExcludeStructuredTrades >

    < ValueID = "1" DisclaimerID > < / DisclaimerID >

    < TradeRisk Value = "F" > < / TradeRisk >

    < MTMsInTradeCurrency Value = "F" > < / MTMsInTradeCurrency >

    < / ValuationRequest >

    Thanks in advance.

    with t as)

    Select xmltype (')

    http://www.w3.org/2001/XMLSchema-instance"container ="http://www.w3.org/2001/XMLSchema"ValueID ="169821"Version ="2.6"xmlns ="http://XBank.FxVals/ProcessValuationRequest.xsd"Status ="AC">

    ActiveChangesApproved

    [email protected]]">

    ') double x

    )

    Select comment_text

    t,.

    XMLTable)

    XmlNamespaces (default 'http://XBank.FxVals/ProcessValuationRequest.xsd'),

    «ValuationRequest / / comment»

    go x

    columns

    comment_text varchar2 (200) path "@Value"

    )

    /

    COMMENT_TEXT
    --------------------------------------------------------------------------------------------------------------------------------------
    Time changed according to the dtd VSG mail 25/01/2013 14:27. Beneficiary SVK added according to mail from Richard dtd 20/02/2013 09:45. SVK

    SQL >

    SY.

Maybe you are looking for