Skip to main content
Nelson Schroth
Participating Frequently
May 20, 2024 2:35 PM UTC

Strange Dictionary results using DY4 conversion

I needed to extract just the 4-digit year from an invoice file.  I created both an "A" and "D" dictionary item using "DY4" (called ORDER.YEAR)

It lists the file perfectly, but when I try to select using ORDER.YEAR it finds nothing:

     ex:  SELECT BILLING WITH ORDER.YEAR EQ "2019"

0 record(s) selected to SELECT list #0.

Also strange - if I add a "[" OR a "]" OR both, it works?

     ex:  SELECT BILLING WITH ORDER.YEAR EQ "[2019"  or

              SELECT BILLING WITH ORDER.YEAR EQ "2019]" or

              SELECT BILLING WITH ORDER.YEAR EQ "[2019]"

My solution was to create an I-discriptor to avoid issues in the future:

0001: I
0002: OCONV(@RECORD<29>,"DY4")
0003:
0004: NYR
0005: 4R
0006: S
0007:

My fellow developers and I could not explain this, as it must be a flaw in the back-end.

Just curious if this could be explained?

Nelson



------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------

    7 replies

    Mike Rajkowski
    Rocketeer
    May 20, 2024 3:31 PM UTC

    I needed to extract just the 4-digit year from an invoice file.  I created both an "A" and "D" dictionary item using "DY4" (called ORDER.YEAR)

    It lists the file perfectly, but when I try to select using ORDER.YEAR it finds nothing:

         ex:  SELECT BILLING WITH ORDER.YEAR EQ "2019"

    0 record(s) selected to SELECT list #0.

    Also strange - if I add a "[" OR a "]" OR both, it works?

         ex:  SELECT BILLING WITH ORDER.YEAR EQ "[2019"  or

                  SELECT BILLING WITH ORDER.YEAR EQ "2019]" or

                  SELECT BILLING WITH ORDER.YEAR EQ "[2019]"

    My solution was to create an I-discriptor to avoid issues in the future:

    0001: I
    0002: OCONV(@RECORD<29>,"DY4")
    0003:
    0004: NYR
    0005: 4R
    0006: S
    0007:

    My fellow developers and I could not explain this, as it must be a flaw in the back-end.

    Just curious if this could be explained?

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    Nelson,

    First I assume this is UniVerse.

    What version of UniVerse and what is the OS?

    Also, What is the flavor account?  

    Note that I tried to recreate the error on my laptop running 11.4.1, and was not able to recreate the issue in the XDEMO account.

    I used:

    >CT DICT MEMBERS ORDER.YEAR

         ORDER.YEAR
    0001 I
    0002 OCONV(@RECORD<10>, "DY4")
    0003
    0004 NYR
    0005 4R
    0006 S

    And was able to select 1962 from the file:

    > SELECT MEMBERS WITH ORDER.YEAR = "1962"

    28 record(s) selected to SELECT list #0.

    Can you try that on your system, and let me know what you get?



    ------------------------------
    Mike Rajkowski
    MultiValue Product Evangelist
    Rocket Internal - All Brands
    US
    ------------------------------
    Nelson Schroth
    Participating Frequently
    May 20, 2024 3:48 PM UTC

    Nelson,

    First I assume this is UniVerse.

    What version of UniVerse and what is the OS?

    Also, What is the flavor account?  

    Note that I tried to recreate the error on my laptop running 11.4.1, and was not able to recreate the issue in the XDEMO account.

    I used:

    >CT DICT MEMBERS ORDER.YEAR

         ORDER.YEAR
    0001 I
    0002 OCONV(@RECORD<10>, "DY4")
    0003
    0004 NYR
    0005 4R
    0006 S

    And was able to select 1962 from the file:

    > SELECT MEMBERS WITH ORDER.YEAR = "1962"

    28 record(s) selected to SELECT list #0.

    Can you try that on your system, and let me know what you get?



    ------------------------------
    Mike Rajkowski
    MultiValue Product Evangelist
    Rocket Internal - All Brands
    US
    ------------------------------

    Hello Mike,

    This is on Universe 11.3.1 running on AIX 7.2

    The I-Descriptor works fine.  It is the "D" and "A" dict items that fail.  

    EX:

    0001: D

    0002: 29

    0003: DY4

    0004: ORD YR

    0005: 4R

    0006: S

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------
    Nelson Schroth
    Participating Frequently
    May 20, 2024 3:49 PM UTC

    Hello Mike,

    This is on Universe 11.3.1 running on AIX 7.2

    The I-Descriptor works fine.  It is the "D" and "A" dict items that fail.  

    EX:

    0001: D

    0002: 29

    0003: DY4

    0004: ORD YR

    0005: 4R

    0006: S

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    Forgot:  PICK flavor



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------
    Mike Rajkowski
    Rocketeer
    May 20, 2024 4:18 PM UTC

    Hello Mike,

    This is on Universe 11.3.1 running on AIX 7.2

    The I-Descriptor works fine.  It is the "D" and "A" dict items that fail.  

    EX:

    0001: D

    0002: 29

    0003: DY4

    0004: ORD YR

    0005: 4R

    0006: S

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    Interesting, I have not seen that before, yet I did find that if you change = to LIKE it will work.

    i.e.

    >SELECT MEMBERS WITH ORDER.YEAR LIKE "1962"

    28 record(s) selected to SELECT list #0.



    ------------------------------
    Mike Rajkowski
    MultiValue Product Evangelist
    Rocket Internal - All Brands
    US
    ------------------------------
    Neil Morris
    Rocketeer
    May 20, 2024 4:21 PM UTC

    Forgot:  PICK flavor



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    Hi Nelson,

    I did a similar test with a "D" type and can see the behavior you reported. Apparently because the field is a date field, when doing the 'DATE.YEAR = "2019"', selection criteria is converted to a specific day. And with the day and month missing, it does the selection against "01/01/2019". Which is why the adding the pattern matching to expand the range of the calculation produces the different result. 

    In the example below, query is looking for a specific date when 'EQ = "2019"' is used. I'm guessing this is long standing behavior related to converting a partial string external date to a specific date. Not expected in this situation but I suspect the behavior exists for some compatibility reasons.

    >LIST NELSON ORDER.DATE ORDER.YEAR

    LIST NELSON ORDER.DATE ORDER.YEAR 04:00:29pm  20 May 2024  PAGE    1
    NELSON.... ORDER.DATE ORDER.YEAR

    1          06/01/22   2022
    2          05/17/19   2019
    4          05/26/19   2019

    3 records listed.
    >LIST NELSON WITH ORDER.YEAR = "2019" EXPLAIN
    Optimizing query block 0
    Tuple restriction: F1 = '18629'

    Driver source: NELSON
    Access method: file scan

    UniVerse/SQL: Press any key to continue or 'Q' to quit
    >RUN BP DATE
    ?18629
    01/01/19
    ?
    >LIST NELSON WITH ORDER.YEAR > 2018 AND < 2020 ORDER.DATE ORDER.YEAR

    LIST NELSON WITH ORDER.YEAR > 2018 AND < 2020 ORDER.DATE ORDER.YEAR 04:02:02pm
    20 May 2024  PAGE    1
    NELSON.... ORDER.DATE ORDER.YEAR

    2          05/17/19   2019
    4          05/26/19   2019

    2 records listed.
    >

    Hope that helps.

    Thanks,

    Neil



    ------------------------------
    Neil Morris
    Universe Advanced Technical Support
    Rocket Software
    ------------------------------
    Brian Speirs
    Participating Frequently
    May 20, 2024 4:26 PM UTC

    I needed to extract just the 4-digit year from an invoice file.  I created both an "A" and "D" dictionary item using "DY4" (called ORDER.YEAR)

    It lists the file perfectly, but when I try to select using ORDER.YEAR it finds nothing:

         ex:  SELECT BILLING WITH ORDER.YEAR EQ "2019"

    0 record(s) selected to SELECT list #0.

    Also strange - if I add a "[" OR a "]" OR both, it works?

         ex:  SELECT BILLING WITH ORDER.YEAR EQ "[2019"  or

                  SELECT BILLING WITH ORDER.YEAR EQ "2019]" or

                  SELECT BILLING WITH ORDER.YEAR EQ "[2019]"

    My solution was to create an I-discriptor to avoid issues in the future:

    0001: I
    0002: OCONV(@RECORD<29>,"DY4")
    0003:
    0004: NYR
    0005: 4R
    0006: S
    0007:

    My fellow developers and I could not explain this, as it must be a flaw in the back-end.

    Just curious if this could be explained?

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    Hi Nelson,

    This is relatively simple to explain.

    Your dictionary applies a conversion to a date value which gives you the output that you want. But the selection gets applied against the real data which is a date.

    Even though some date conversions let you select in external format (such as selecting for a date greater than "01 JAN 2024"), that does not apply to all conversions. In another MV product, the distinction was explained this way: You can use the external format when the conversion operates in both directions i.e. if you ICONV your external format, you get returned back to your original data value.

    So, date today is 20596. Applying an OCONV (with a D conversion)  to that date value returns "21 May 2024". Applying an ICONV to that external date returns us to 20596.

    But you can't do that with a year. Applying a DY conversion to that date gives us 2024, but I can't ICONV the 2024 to get back to the original date value. Therefore, you cannot SELECT the year if the year is only calculated in the conversion - but you CAN select on the year if you have calculated it in an expression.

    I hope that makes sense to you.

    Brian



    ------------------------------
    Brian Speirs
    Senior Analyst - Information Systems
    Rush Flat Ltd
    Wellington NZ
    ------------------------------
    Nelson Schroth
    Participating Frequently
    May 20, 2024 4:45 PM UTC

    Hi Nelson,

    This is relatively simple to explain.

    Your dictionary applies a conversion to a date value which gives you the output that you want. But the selection gets applied against the real data which is a date.

    Even though some date conversions let you select in external format (such as selecting for a date greater than "01 JAN 2024"), that does not apply to all conversions. In another MV product, the distinction was explained this way: You can use the external format when the conversion operates in both directions i.e. if you ICONV your external format, you get returned back to your original data value.

    So, date today is 20596. Applying an OCONV (with a D conversion)  to that date value returns "21 May 2024". Applying an ICONV to that external date returns us to 20596.

    But you can't do that with a year. Applying a DY conversion to that date gives us 2024, but I can't ICONV the 2024 to get back to the original date value. Therefore, you cannot SELECT the year if the year is only calculated in the conversion - but you CAN select on the year if you have calculated it in an expression.

    I hope that makes sense to you.

    Brian



    ------------------------------
    Brian Speirs
    Senior Analyst - Information Systems
    Rush Flat Ltd
    Wellington NZ
    ------------------------------

    Thanks Brian...makes sense.



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------