JDBC MS Access--- cannot extract entry with null value with data type Meta

I'm trying to extract a data entry with null value by using JDBC. The database is MS Access.
The question is how to extract null entry with data type memo? The following code works when the label has data type Text, but it throws sqlException when the data type is memo.
Any advice will be appreciated! thanks!
Following are the table description and JDBC code:
test table has the following attributes:
Field name Data Type
name Text
label Memo
table contents:
name label
me null
you gates
Code:
String query = "SELECT name, label FROM test where name like 'me' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
String name = rs.getString("name");
rs.getString("val");
String label = rs.getString("label");
System.out.println("\t"+name+"\t"+label);
catch (SQLException ex)
System.out.println(ex.getSQLState());
System.out.println(ex.getErrorCode());
System.out.println("in sqlexception");
output:
C:\Temp\SEFormExtractor>java DBTest
yet SELECT name, label FROM test
null
0
in sqlexception

The question is how to extract null entry with data type memo?Okay, what you need to do is this:
if (rs.getString("val") == null)
  // do something
}This way, when it's a null value, you can check it first, and then handle it how you want, rather than getting an exception.

Similar Messages

  • 1.5.1: Excel import - Problem with NULL values in date fileds

    Hi,
    I'm trying to import Excel Data via CSV with the import into table feature of SQLDeveloper.
    Everything works fine, but if I select some of my date colums I get an error telling me that I have null or invalid values in a date column:
    Verifying if the Date columns have date formats
    FAILED
    Date columns SOA_CONTROLLING_NO, SOA_DATE_OF_CONTROLLING, PAYOUT_ME_2_SUM, PAYOUT_ME_1_SUM, PAYOUT_PLUS_SUM, PAYOUT_6_SUM, PAYOUT_5_SUM, PAYOUT_4_SUM, PAYOUT_3_SUM, PAYOUT_2_SUM, PAYOUT_1_SUM, CONTRACT_APPENDIX_SUM, CONTRACT_BASE_SUM, ME_CONVENANT_SUM, REF_SUM_NO_REPAY, SEL_CONVENANT_SUM, ME_REQ_SUM, REF_REQ_SUM_NO_REPAY, SEL_REQ_SUM,  have invalid or null date formats
    I tried:
    +20012121313,demo1,,+
    +20012121313,demo1,NULL,+
    +20012121313,demo1,to_date(NULL),+
    but none of them worked...
    How may I import those columns, where some of the rows contain NULL values?
    Same story using 1.5... ;-(
    Thank you!
    Best regards,
    Johann

    Look at the query Andy proposed:
    SELECT NULL LINK, start_date, NVL(sum_of_trans, 0) + 0.001 VALUE
      FROM (SELECT   TRUNC (startdate) start_date,
                     CASE
                        WHEN :p9_view_by = 1
                           THEN ROUND (DURATION / 60, 3)
                        ELSE 1
                     END sum_of_trans
                FROM TRANSACTION
               WHERE trans_id = x AND startdate BETWEEN y AND z
            GROUP BY TRUNC (startdate)) xDoes this query deliver anything?
    Denes Kubicek

  • JDBC Receiver Adapter with Null Value

    HI,
    I have configured ID for JDBC Receiver. In my communication channel, I already check Integration of Empty String Values = Null Value. However, when I check the result from audit log, it still shows that SAP XI sends the null value to database. In my understanding, it should not send the field which has null value (It shouldn't be included in sql statement).
    I check this with other scenario. With the same check at Integration of Empty String Values = Null Value, it doesn't send null value to database. It happens only with my first scenario.
    Have anyone ever been through this before? Any suggestion please?
    Thanks,
    Pavin

    Hi,
    1. The occurrence is 0...1
    2. This is the first result with null value (Please see field Error)
    UPDATE EXPCRM_T_CustomerProfile SET RequestID=455, RecordNo=1, SAPCustomerCode=0001000344, Error=NULL, Status=2, UpdateDateTime=12/03/2008 13:45:03 WHERE (RequestID=455 AND RecordNo=1)
    Then, I change the option from Null Value to Empty string. This is the result.
    UPDATE EXPCRM_T_CustomerProfile SET RequestID=455, RecordNo=1, SAPCustomerCode=0001000344, Error=', Status=2, UpdateDateTime=12/03/2008 13:46:12 WHERE (RequestID=455 AND RecordNo=1)
    Field Error Change from NULL to '
    The expected result from me is that field Error should not exist at all. Please help.
    Thanks,
    Pavin

  • Pro*C & SQLDA with NULL value for predicate column

    Hi: I am using a C program to update a table via a dynamic sql (method 4) and SQLDA. In the update statement predicate, I have place holders (as in TBLCOL=:C000). One of the columns in the predicate contains null values, so I set L[n] = 0, V[n] = pData (which pData[0] = '\0'), *(I[n]) = -1, and T[n] = 5 (for text). I cannot find the row that I know is there.
    I cannot change my statement to contain TBLCOL IS NULL, since I don't know ahead of time if I'm looking for rows with null values for this column. The Pro*C manual says that by setting the appropriate *(I[n]) = -1, it indicates to Oracle to simulate the "IS NULL" clause, and update the appropriate rows. In my case, I receive 1403 as SQLCODE when I use TBLCOL=:C000 vs TBLCOL IS NULL. What am I doing wrong? Thank you for your help.

    You should include these columns as well;
    ChangeType (see mxi_changetype)
    ValOwner (repository)
    UserID ("jobid=<>", usermskey, GUI (mmc), DG (dyngrp), reconcile)
    IdAudit  (This is the event task (add and del member for assignments)
    ParentAuditId (AuditID of parent which last updated the attribute, not consistent)
    ChangedBy (Holds the MSKEY of the user which last changed the attribute)
    ExpiryTime
    to make sure you get a fuller picture of the audit record.
    Your selection does not cover all events and descriptions
    br,
    Chris

  • Need help with NULL values in Crosstables

    Hello everybody,
    I need some help with NULL values and crosstables. My issue is the following:
    I have a query (BW - MDX-Query) that gives me turnover measures for each month. In Crystal Reports I choose crosstable to display this whereby I put all month in columns and all turnover-measures in rows. Each month that has a value (measures are not empty) is chown in the crosstables rows. So far so good. The problem occures when there are month that actually have no values (measures are empty). In that case these months are not chown in columns. But I need CR to display these columns and show the value 0. How can I do that?

    Hi Frank,
    Cross tab shows the data based on your column and these column fields are grouped and based on the group it will show your summaries. 
    If there is no data for any of your group it will not display that group.  In this case you will have to create a standard report which should look like cross tab and to get zero values you need to write formulas .
    Example if you want to display Moth wise sales :
    if Month() = 01 Then
    sum() else 0
    Now this formula will check if your month is Jan, then it will sum up the values else it will display zero value. 
    This is possible only through standard report not with Cross Tab.
    Thanks,
    Sastry

  • How to create a dimension object in SAP BW Unv with Null value

    Hello,
    for query syncronisation task, I need a dimension object in my BW universe with NULL value. Does someone know, how to do it or if its possible?
    Regards,
    Thilo

    Hi Thilo,
    so the only common item is Material then - correct ?
    Query 1                                                                                Query 2
    Formulation (grouping of materials)                                                  (No counterpart)
    Material                                                                                Material
    dummy key figure (why?)                                                                Company Code
                                                                                    10 Keyfigure
    Is this something you regular have to do ? what about a MultiProvider ?
    did you try "merged dimensions" in the Web Intelligence Report ?
    Ingo

  • Sql query slowness due to rank and columns with null values:

        
    Sql query slowness due to rank and columns with null values:
    I have the following table in database with around 10 millions records:
    Declaration:
    create table PropertyOwners (
    [Key] int not null primary key,
    PropertyKey int not null,    
    BoughtDate DateTime,    
    OwnerKey int null,    
    GroupKey int null   
    go
    [Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
    With the following index:
    CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]    
    [PropertyKey] ASC,   
    [BoughtDate] DESC,   
    [OwnerKey] DESC,   
    [GroupKey] DESC   
    go
    Description of the case:
    For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
    following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
    declare @ownerKey int = 40000   
    select PropertyKey, BoughtDate, OwnerKey, GroupKey   
    from (    
    select PropertyKey, BoughtDate, OwnerKey, GroupKey,       
    RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]   
    from PropertyOwners   
    ) as result   
    where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
    It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
    May be the slowness is due to as OwnerKey/GroupKey in the table  can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
    view.
    Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.

    create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
    insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
    select PropertyKey, BoughtDate, OwnerKey, GroupKey,
    RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
    from PropertyOwners
    go
    declare @ownerKey int = 1
    select PropertyKey, BoughtDate, OwnerKey, GroupKey
    from #result as result
    where result.[Rank]=1
    and result.[OwnerKey]=@ownerKey
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • bc4juix:StyledText doesn't work with null values?

    Hi , anyone knows why the <bc4juix:StyledText> tag doesn't work with null values?
    For example when datasource does not give back data...
    Thanks
    Guillermo

    Which version of Jdev are you using? What are the results you are getting?

  • Range interval partitioning with null value

    Hello,
    I have question, how can I create table with partition and after that I will insert null value in the partition key like this kind of
    range interval partitioning with null value.
    I have Oracle 11g.
    Thanks
    Mohammed

    user13777053 wrote:
    Thank you, but my question is about range interval not for range?http://docs.oracle.com/cd/E11882_01/server.112/e25523/partition.htm#VLDBG00220
    A MAXVALUE literal can be defined for the highest partition. MAXVALUE represents a virtual infinite value that sorts higher than any other possible value for the partitioning key, *including the NULL value.*
    So since you're trying to partition by interval (which doesn't support a MAXVALUE clause) you're out of luck.
    There's probably fancy hacks and what not you could try to implement, but i'm not about to recommend any of those here :)
    Cheers,

  • To overcome column with null value-urgent

    hai all,
    when i query i get column with null value.
    how to solve it?
    thank in advance.
    rcs
    SQL> DESC SCOTT.CB1;
    Name Null? Type
    ID NUMBER
    SUPCODE NUMBER
    SUPLNAME VARCHAR2(100)
    NAME VARCHAR2(100)
    ITEMCODE VARCHAR2(10)
    RECDOC NUMBER
    RECDATE VARCHAR2(10)
    TOTVALUE NUMBER
    QTY NUMBER
    CB_IPNO NUMBER
    CB_VNNO NUMBER
    CB_VDT VARCHAR2(10)
    CB_AMT NUMBER
    RECDOC_GR VARCHAR2(30)
    RECDATE_GR DATE
    SUPCODE_GR VARCHAR2(10)
    TABLE LOOK LIKE THIS (NOT ALL DATA IN SAME ROW, BECUSE I INSERTED LAST 3 COLUMN VALUES):
    ID     SUPCODE     SUPLNAME     NAME     ITEMCODE     RECDOC     RECDATE     TOTVALUE     QTY     CB_IPNO     CB_VNNO     CB_VDT     CB_AMT     RECDOC_GR     RECDATE_GR     SUPCODE_GR
    2015               AAAA                04117     9083          10545.6     78                                   
    2016               BBBB                    04609     9087          25200     3600                                   
    2017               GGGG                    04609     9088          28175     4025                                   
    2018                                   36591371.64     2565017.27                                   
                                                                     00001/07-08     02/04/2007     14020362
                                                                     00002/07-08     02/04/2007     14020362
                                                                     00003/07-08     02/04/2007     14010254
                                                                     00004/07-08     02/04/2007     14010254
                                                                     00005/07-08     02/04/2007     14021458
    SQL> SELECT DISTINCT ID, SUPCODE_GR, NAME, ITEMCODE, RECDOC, RECDATE_GR, TOTVALUE, QTY FROM SCOTT.CB
    1;
    ID SUPCODE_GR
    NAME
    ITEMCODE RECDOC RECDATE_G TOTVALUE QTY
    1
    PRO.AT.ALU.POWDER UNCOATED
    04609 15 51975 7425
    2
    PEN, GEL PEN
    07969 17 154 11
    ID SUPCODE_GR
    I NEED RESULT AS FOLLOWS (ALL RESPECTIVE DDATA IN ONE LINE NOW NOT LIKE THAT):
    ID     SUPCODE     SUPLNAME     NAME     ITEMCODE     RECDOC     RECDATE     TOTVALUE     QTY     CB_IPNO     CB_VNNO     CB_VDT     CB_AMT     RECDOC_GR     RECDATE_GR     SUPCODE_GR
    2015               AAAA                04117     9083          10545.6     78                         00001/07-08     02/04/2007     14020362                              
    ============

    Even accounting for the formatting, I'm not sure I even understand the question. It could be any number of different problems or non-problems.

  • Issue with 'null' value in Formulas

    Hi all - I have a PDF in which I'm performing various calculations, basic addition and subtraction.  I'm using the following Custom Calculation Script:
    this.getField("Amount, Total Revenue Allocated to Maintenance Expenses").value = this.getField("Amount, Endowment Care Fund Income - Schedule H").value + this.getField("Amount, Special Care Fund Income - Schedule H").value + this.getField("Amount, Income from Cemetery Operations").value + this.getField("Amount, Other Sources Please Specify").value;
    My issue is that when someone deletes a value in one of the fields (which I guess causes the field to be 'NULL'), the calcualtion doesn't work....so in other words if I have the following:
    Field 1:  10
    Field 2:  20
    Field 3:  30
    Field 4:  40
    When adding this should result in 100.....however if one were to delete the value in field 2, my calcualtion then produces 103,040....the formula doesn't know how to process the NULL value of course, so it concatenates the numbers.
    How do I get around this?  Do I need more JavaScript, and if so is there a good example somewhere on how to code it?
    Thanks, Steve

    leahfst,
    If these dates are complementary (as in 'either date1 either date2 has a value) you could transform the dates to text, merge these two fields (one being empty) and convert the result back to a date:
    Date(ToText({CnFGf_1.CnFGf_1_Date}) & ToText({CnFGf_2.CnFGf_2_Date}))
    If these dates can both have a value (or not), it is helpful to know a null-value for dates is equal to Date(0000,00,00). In this situation, there can be the following situations:
    1. Both dates are empty. Your result will obviously be an empty date.
    2. {CnFGf_1.CnFGf_1_Date} has a value, {CnFGf_2.CnFGf_2_Date} is empty.
    3. {CnFGf_1.CnFGf_1_Date} is empty, {CnFGf_2.CnFGf_2_Date} has a value.
    4. Both dates have a value. You will have to choose which date should be used.
    For any of these four situations, you can check the date to have a value using:
    IF {CnFGf_1.CnFGf_1_Date} = Date(0000,00,00)
    and so on..

  • Issue with Oracle LONG RAW data type

    Hi All,
    I am facing some issues with Oracle LONG RAW DATA Type.
    We are using Oracle 9IR2 Database.
    I got a table having LONG RAW column and I need to transfer the same into another table having LONG RAW column.
    When I tried using INSERT INTO SELECT * command (or) CREATE TABLE as select * , it is throwing ORA-00997: illegal use of LONG datatype.
    I have gone through some docs and found we should not use LONG RAW using these operations.
    So I did some basic PLSQL block given below and I was able to insert most of the records. But records where the LONG RAW file is like 7O kb, the inserting is faliling.
    I tried to convert LONG RAW to BLOB and again for the record where the LONG RAW is big in size I am getting (ORA-06502: PL/SQL: numeric or value error) error.
    Appreciate if anyone can help me out here.
    DECLARE
    Y LONG RAW;
    BEGIN
    FOR REC IN (SELECT * FROM TRU_INT.TERRITORY WHERE TERRITORYSEQ=488480 ORDER BY TERRITORYSEQ ) LOOP
    INSERT INTO TRU_CMP.TERRITORY
    BUSINESSUNITSEQ, COMPELEMENTLIFETIMEID, COMPONENTIMAGE, DESCRIPTION, ENDPERIOD, GENERATION, NAME, STARTPERIOD, TERRITORYSEQ
    VALUES
    REC.BUSINESSUNITSEQ, REC.COMPELEMENTLIFETIMEID, REC.COMPONENTIMAGE, REC.DESCRIPTION, REC.ENDPERIOD, REC.GENERATION, REC.NAME,
    REC.STARTPERIOD, REC.TERRITORYSEQ
    END LOOP;
    END;
    /

    Maddy wrote:
    Hi All,
    I am facing some issues with Oracle LONG RAW DATA Type.
    We are using Oracle 9IR2 Database.
    I got a table having LONG RAW column and I need to transfer the same into another table having LONG RAW column.
    When I tried using INSERT INTO SELECT * command (or) CREATE TABLE as select * , it is throwing ORA-00997: illegal use of LONG datatype.
    I have gone through some docs and found we should not use LONG RAW using these operations.
    So I did some basic PLSQL block given below and I was able to insert most of the records. But records where the LONG RAW file is like 7O kb, the inserting is faliling.
    I tried to convert LONG RAW to BLOB and again for the record where the LONG RAW is big in size I am getting (ORA-06502: PL/SQL: numeric or value error) error.
    Appreciate if anyone can help me out here.
    DECLARE
    Y LONG RAW;
    BEGIN
    FOR REC IN (SELECT * FROM TRU_INT.TERRITORY WHERE TERRITORYSEQ=488480 ORDER BY TERRITORYSEQ ) LOOP
    INSERT INTO TRU_CMP.TERRITORY
    BUSINESSUNITSEQ, COMPELEMENTLIFETIMEID, COMPONENTIMAGE, DESCRIPTION, ENDPERIOD, GENERATION, NAME, STARTPERIOD, TERRITORYSEQ
    VALUES
    REC.BUSINESSUNITSEQ, REC.COMPELEMENTLIFETIMEID, REC.COMPONENTIMAGE, REC.DESCRIPTION, REC.ENDPERIOD, REC.GENERATION, REC.NAME,
    REC.STARTPERIOD, REC.TERRITORYSEQ
    END LOOP;
    END;
    /below might work
    12:06:23 SQL> help copy
    COPY
    Copies data from a query to a table in the same or another
    database. COPY supports CHAR, DATE, LONG, NUMBER and VARCHAR2.
    COPY {FROM database | TO database | FROM database TO database}
                {APPEND|CREATE|INSERT|REPLACE} destination_table
                [(column, column, column, ...)] USING query
    where database has the following syntax:
         username[/password]@connect_identifier

  • IT0041 - employee with more than 12 date types;

    Has anyone had an instance where an employee has had more than 12 valid Date Types on IT0041?  If so, how did you enter their 13th date type?  We have just created our 12th date type in the table and we will probably be creating a 13th date type in the near future.  We have a number of employees who already use 11 date types and could use the 2 new ones as well.  I tried to create a new Subtype for my new Date Type - but the new Subtype requires that Date Type 01 be entered.  I am not comfortable with having two identical Date Type 01s in IT0041 (one on Subtype 0001 and one on Subtype 0098). 
    Has anyone used more than one Subtype on IT0041?

    Thank you for your responses.  I don't think changing the Time Constraint class is the best solution for our organization.  We did look at that option.  I don't want to have multiple valid records; I want the ability to have more than 12 date types (values) on one record.  Also, if we allow more than one record, SAP forces us to have Date Type 01 on both valid records - I would be concerned that these values may not match, and then Time Eval would bomb. 
    I'm also still curious if anyone has used more than one Subtype on IT0041?  Again, we did try this, but SAP forces a Date Type 01 on both Subtypes.

  • How no to select lines with NULL values

    Hi,
    I am not a newbie newbie in SQL but I do not understand why I cannot retrieve the lines where there are null values.
    The table observatoire.fiche has 2 columns with default values set to NULL : total_heures, and total_heures_exceptionnelles. These are numeric types columns.
    I want not to select lines where :
    total_heures equal NULL AND total_heures_exceptionnelles = NULLI have tried this but I do get an "Invalid relational operator" error message.
    select a.nom || ' ' || a.prenom d, a.agent_id r
    from   OBSERVATOIRE.AGENT a, observatoire.fiche b
    where  a.agent_id = b.agent_id
    and    b.total_heures NOT NULL AND total_heures_exceptionnelles NOT NULL
    group by a.nom, a.prenom, a.agent_id
    order by a.nomCould you help me ?
    Thank you for your kind answers.

    Satyaki_De wrote:
    I think this is not the good way to do it. Did you check my solution? It should work the same output as your solution.Really ?
    test@ORA10G>
    test@ORA10G> -- (1)
    test@ORA10G> with t as (
      2    select 1 as x, 10 as total_heures, null as total_heures_exceptionnelles from dual union all
      3    select 1, null, 20   from dual union all
      4    select 1, null, null from dual union all
      5    select 1, 30, 40     from dual)
      6  --
      7  select x, total_heures, total_heures_exceptionnelles
      8  from   t
      9  where  x = 1
    10  AND NOT ( total_heures IS  NULL
    11            AND
    12            total_heures_exceptionnelles IS NULL
    13          );
             X TOTAL_HEURES TOTAL_HEURES_EXCEPTIONNELLES
             1           10
             1                                        20
             1           30                           40
    test@ORA10G>
    test@ORA10G> -- (2)
    test@ORA10G> with t as (
      2    select 1 as x, 10 as total_heures, null as total_heures_exceptionnelles from dual union all
      3    select 1, null, 20   from dual union all
      4    select 1, null, null from dual union all
      5    select 1, 30, 40     from dual)
      6  --
      7  select x, total_heures, total_heures_exceptionnelles
      8  from   t
      9  where  x = 1
    10  AND    total_heures IS NOT NULL
    11  AND    total_heures_exceptionnelles IS NOT NULL;
             X TOTAL_HEURES TOTAL_HEURES_EXCEPTIONNELLES
             1           30                           40
    test@ORA10G>
    test@ORA10G>isotope

  • REGEXP_SUBSTR for comma delimited list with null values

    Hi,
    I have a column which stores a comma delimited list of values. Some of these values in the list may be null. I'm having some issues trying to extract the values using the REGEXP_SUBSTR function when null values are present. Here are two things that I've tried:
    SELECT
       REGEXP_SUBSTR (val, '[^,]*', 1, 1) pos1
      ,REGEXP_SUBSTR (val, '[^,]*', 1, 2) pos2
      ,REGEXP_SUBSTR (val, '[^,]*', 1, 3) pos3
      ,REGEXP_SUBSTR (val, '[^,]*', 1, 4) pos4
      ,REGEXP_SUBSTR (val, '[^,]*', 1, 5) pos5
    FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual);
    POS P POS P P
    AAA   BBB
    SELECT
       REGEXP_SUBSTR (val, '[^,]+', 1, 1) pos1
      ,REGEXP_SUBSTR (val, '[^,]+', 1, 2) pos2
      ,REGEXP_SUBSTR (val, '[^,]+', 1, 3) pos3
      ,REGEXP_SUBSTR (val, '[^,]+', 1, 4) pos4
      ,REGEXP_SUBSTR (val, '[^,]+', 1, 5) pos5
    FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual);
    POS POS POS POS P
    AAA BBB DDD FFFAs you can see neither of the calls works correctly. Does anyone know how to modify the regular expression pattern to handle null values? I've tried various other patterns but was unable to get anyone to work for all cases.
    Thanks,
    Martin
    http://www.ClariFit.com
    http://www.TalkApex.com

    Hi, Martin,
    This does what you want:
    SELECT
       RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 1), ',') pos1
      ,RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 2), ',') pos2
      ,RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 3), ',') pos3
      ,RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 4), ',') pos4
      ,RTRIM (REGEXP_SUBSTR (val || ','
                          , '[^,]*,', 1, 5), ',') pos5
    FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual);The query above works in Oracle 10 or 11, but in Oracle 11, you can also do it with just REGEXP_SUBSTR, without using RTRIM:
    SELECT
       REGEXP_SUBSTR (val, '([^,]*),|$', 1, 1, NULL, 1) pos1
      ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 2, NULL, 1) pos2
      ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 3, NULL, 1) pos3
      ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 4, NULL, 1) pos4
      ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 5, NULL, 1) pos5
    FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual);The problem with your first query was that it was looking for sub-strings of 0 or more non-commas. There was such as sub-string. consisting of 3 characters, starting at position 1, so it returned 'AAA', as expected. Then there was another sub-string, of 0 characters, starting at position 4, so it returned NULL. Then there was a sub-string of 3 characters starting at position 5, so it returned 'BBB'.
    The problem with your 2nd query was that it was looking for 1 or more non-commas. 'DDD' is the 3rd such sub-string.
    Edited by: Frank Kulash on Feb 16, 2012 11:36 AM
    Added Oracle 11 example

Maybe you are looking for

  • I opened original iPhoto Library (from iMac 10.8.5) on new MBP and now it won't open on iMac

    As my main computer I use an iMac which is not yet updated to Mavericks and I'd rather not update for now. I recently bought a MBP retina which has Mavericks on it. Whilst I was using the shared network to copy over some files to my new macbook I ope

  • How can I make this AppleScript available as a control click menu?

    This code was previously created in another question from 2009 (https://discussions.apple.com/thread/1881786?start=15&tstart=0), but the last person to comment on it was never given an answer. I wanted to see if this following AppleScript could be us

  • Matrox MX02 with CS6

    Hi, any ideas if the matrox mxo2 works well with cs6, have a chance to buy one loacally for a low price. I am aware that there has been issues in the past with matrox products, is it still the same. any other recoemndations for a I/o Baz

  • Login credidentials and HandlerChain problem

    hi, i have a problem with getting user who call a web service and logging soap message together. i was getting a user with this code: Logger log = LoggerFactory.getLogger(""); String login = ""; IUser user = UMFactory.getAuthenticator().getLoggedInUs

  • CP5: Problems with Execute Javascript and New/Current window setting

    Hello everyone, I am at my wits' end trying to set this up properly, and I was hoping for some help. I have inserted a series of buttons designed to open other captivate-created HTM files. I wanted the files to be opened in a controlled window, so I