Adding a case sensitive field to a dynamic temp-table - Forum - OpenEdge Development - Progress Community

Adding a case sensitive field to a dynamic temp-table

 Forum

Adding a case sensitive field to a dynamic temp-table

This question is answered

Hi,

Am I correct to conclude that a dynamic temp-table can't have a case sensitive field unless you define it LIKE an existing case sensitive db field?

You can't seem to use ttHandle:ADD-NEW-FIELD() but need ttHandle:ADD-LIKE-FIELD(), which is problematic if you don't have a suitable field, or no db connection at all...

There is a CASE-SENSITIVE attribute on buffer field, but that is read only according to the documentation...

Verified Answer
All Replies
  • Correct.

    Sent from Nine

    Von: Lieven De Foor <bounce-lievendefoormipsbe@community.progress.com>
    Gesendet: Freitag, 17. Januar 2020 12:15
    An: TU.OE.Development@community.progress.com
    Betreff: [Technical Users - OE Development] Adding a case sensitive field to a temp-table

    Update from Progress Community
    Lieven De Foor

    Hi,

    Am I correct to conclude that a temp-table (static or dynamic) can't have a case sensitive field unless you define it LIKE an existing case sensitive db field?

    You can't seem to do this:

    DEFINE TEMP-TABLE myTT NO-UNDO

        FIELD caseSensitive AS CHARACTER CASE-SENSITIVE.

    Using ttHandle:ADD-NEW-FIELD() you can't specify case sensitivity either.

    The only way I see it possible is using FIELD caseSensitive LIKE someCaseSensitiveDbField or ttHandle:ADD-LIKE-FIELD(), which is problematic if you don't have a suitable field, or no db connection at all...

    There is a CASE-SENSITIVE attribute on buffer field, but that is read only according to the documentation...

    View online

     

    You received this notification because you subscribed to the forum.  To stop receiving updates from only this thread, go here.

    Flag this post as spam/abuse.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • Thanks Mike, I'll add a feature request for this one.

  • Votes can be added here: openedge.ideas.aha.io/.../OPENEDGE-I-689

  • By the way, what’s your use-case? The base64-shortened GUID’s? That would be mine.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • We have quite a few use cases.

    Blood Rhesus is a good example (en.wikipedia.org/.../Rh_blood_group_system), where Rh antigens C and c are not the same at all.

  • for a STATIC temp-table case sensitive works fine:

    define temp-table tt

      field cc as char case-sensitive

      .

    def var cname as char.

    create tt. tt.cc = "Hi".

    message

      tt.cc = "hi"  skip

      tt.cc = "Hi"

    view-as alert-box.

    using a static temp-table case-sensitive field for the like of a dynamic field does not pass case-sensitive attribute over.

  • We fixed a bug similar to this in the DOH.
     
    You can ADD-LIKE-FIELD() from another temp-table. So we have a TT
        /* We never add records to this, just use it for schema creation */
        define private static temp-table ttCaseSensitive no-undo
            field csChar as character case-sensitive
            field csClob as clob case-sensitive
            .
     
    And code to use them like
                case ablType:
                    when 'character':u then
                        hTable:add-like-field(oField:GetCharacter(string(ServiceMappingFileSchemaEnum:name)),
                                              'ttCaseSensitive.csChar':u).
                    when 'clob':u then
                        hTable:add-like-field(oField:GetCharacter(string(ServiceMappingFileSchemaEnum:name)),
                                              'ttCaseSensitive.csClob':u).
                end case.
                else
                    hTable:add-new-field(oField:GetCharacter(string(ServiceMappingFileSchemaEnum:name)),
                                         ablType,
                                         iExtent).
               
     
    Our use-case/bug was limited to fields that are in an index, so the above 2 fields suffice. If you have array fields you are likely to have more problems (since you'll need a static field for each EXTENT <n>).
     
    Hth,
    -- peter
     
  • Thanks for correcting me on the static temp-table possibility to add CASE-SENSITIVE, which is what Peter's workaround is based on (nice one!)

    I will adjust the original post for correctness sake.

  •  As I wrote, using the static tt for the dynamic tt does not inherit the case-sensitive - (on 11.7.4 or 12.0):

    define temp-table tt

      field cc as char case-sensitive

      .

    create tt. tt.cc = "Hi".

    message tt.cc = "Hi".

    message tt.cc = "hi".

    def var ht as handle no-undo.

    def var hb as handle no-undo.

    create temp-table ht.

    ht:add-like-field( "cc", "tt.cc" ).

    ht:temp-table-prepare( "tt" ).

    hb = ht:default-buffer-handle.

    hb:buffer-create().

    hb::cc = "Hi".

    message hb::cc = "Hi".

    message hb::cc = "hi".

    abldojo.services.progress.com:443/

  • And an updated snippet that shows what a case-sensitive compare should have resulted in:

    define temp-table tt 
       field cc as char case-sensitive
       .
    
    create tt. tt.cc = "Hi".
    
    message tt.cc = "Hi" compare( tt.cc, "=", "Hi", "case-sensitive" ).
    message tt.cc = "hi" compare( tt.cc, "=", "hi", "case-sensitive" ).
    
    def var ht as handle no-undo.
    def var hb as handle no-undo.
    
    create temp-table ht.
    ht:add-like-field( "cc", "tt.cc" ).
    ht:temp-table-prepare( "tt" ).
    hb = ht:default-buffer-handle.
    
    hb:buffer-create().
    hb::cc = "Hi".
    
    message hb::cc = "Hi" compare( hb::cc, "=", "Hi", "case-sensitive" ).
    message hb::cc = "hi" compare( hb::cc, "=", "hi", "case-sensitive" ).



    yes yes
    no no
    yes yes
    yes no !!!

  • Ugh. Adding
    message 'CS:' hb:buffer-field('cc'):case-sensitive.
     
    Returns 'yes' in that snippet. But as you say, the EQ  doesn't work.
     
    That's definitely a bug.
     
    (My mea cupla is that my unit tests were around getting the reflection to pass, not testing the values of the fields).
     
     
  • Stefan, have you logged this with technical support? Is there a bug or case number?

  •  No, it has no impact for me, but I have given feedback on knowledgebase.progress.com/.../Can-t-add-the-DECIMALS-and-CASE-SENSITIVE-field-options-with-the-ADD-NEW-FIELD-method that case-sensitive does not work.

  • But it gets even better - case-sensitive is the new gift that keeps on giving. There is a difference between the handling of hb:cc and hb:buffer-field( "cc" ):buffer-value - as in real life, it never pays to take shortcuts Geeked

    define temp-table tt 
       field cc as char case-sensitive
       .
    
    create tt. tt.cc = "Hi".
    
    message tt.cc = "Hi" compare( tt.cc, "=", "Hi", "case-sensitive" ).
    message tt.cc = "hi" compare( tt.cc, "=", "hi", "case-sensitive" ).
    
    def var ht as handle no-undo.
    def var hb as handle no-undo.
    
    create temp-table ht.
    ht:add-like-field( "cc", "tt.cc" ).
    ht:temp-table-prepare( "tt" ).
    hb = ht:default-buffer-handle.
    
    hb:buffer-create().
    hb::cc = "Hi".
    
    message hb::cc = "Hi" compare( hb::cc, "=", "Hi", "case-sensitive" ).
    message hb::cc = "hi" compare( hb::cc, "=", "hi", "case-sensitive" ).
    message hb:buffer-field( "cc" ):buffer-value = "hi" compare( hb:buffer-field( "cc" ):buffer-value, "=", "hi", "case-sensitive" ).

  • OK, I'll create a case for this then.