informix extract part of string

Posted on 2012-08-13
Last Modified: 2013-04-07
I have a table

ID --- Note
1 ----- 0240231123 merged to ID 02427299912              
2 ----- 0242296335 merged to ID P125903                

I would like to extract only the first value in the note using a SQL query:

ID --- value ----------------- Note
1 ----- 0240231123 ---- 0240231123 merged to ID 02427299912              
2 ----- 97996536 ---------97996536 merged to ID P125903    

not sure what the sql query is?
Question by:JCTDD
    LVL 7

    Accepted Solution

    If you're using Informix 11.7, you can use CHARINDEX( ) or INSTR( ) function together with SUBSTR( ).
    But it seems those two are newly introduced in Informix 11.7
    If you have an older version, you need to create a UDR in C or java language...

    Or you can try something like this:

        WHEN note[1] = ' ' THEN ''
        WHEN note[2] = ' ' THEN note[1]
        WHEN note[3] = ' ' THEN note[1,2]
        WHEN note[4] = ' ' THEN note[1,3]
        WHEN note[5] = ' ' THEN note[1,4]
    FROM your_table

    Yes, it's kind of dumb, but it should work.
    LVL 31

    Expert Comment

    What version of Informix are you using?

    Author Comment

    using informix version 10

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    This article describes some very basic things about SQL Server filegroups.
    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now