Adding a case sensitive field to a dynamic temp-table

Posted by Lieven De Foor on 17-Jan-2020 11:14

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...

Posted by Lieven De Foor on 17-Jan-2020 11:43

All Replies

Posted by Mike Fechner on 17-Jan-2020 11:20

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.

Posted by Lieven De Foor on 17-Jan-2020 11:24

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

Posted by Lieven De Foor on 17-Jan-2020 11:43
Posted by Mike Fechner on 17-Jan-2020 11:48

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

Posted by Lieven De Foor on 17-Jan-2020 11:58

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.

Posted by Stefan Drissen on 17-Jan-2020 12:11

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.

Posted by Peter Judge on 17-Jan-2020 14:26

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
 

Posted by Lieven De Foor on 17-Jan-2020 14:48

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.

Posted by Stefan Drissen on 17-Jan-2020 15:15

[mention:9e4ee96fac634b8f91b580e1fb4f7e71:e9ed411860ed4f2ba0265705b8793d05]  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/

Posted by Stefan Drissen on 17-Jan-2020 15:26

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 !!!

Posted by Peter Judge on 17-Jan-2020 15:30

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).
 
 

Posted by Lieven De Foor on 17-Jan-2020 15:40

Stefan, have you logged this with technical support? Is there a bug or case number?

Posted by Stefan Drissen on 17-Jan-2020 15:48

[mention:04e040a388574bee96c841b1935762a5:e9ed411860ed4f2ba0265705b8793d05]  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.

Posted by Stefan Drissen on 17-Jan-2020 15:52

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 [8-|]

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" ).

Posted by Lieven De Foor on 17-Jan-2020 15:53

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

Posted by Peter Judge on 17-Jan-2020 15:58

I've logged a bug (OCTA-18909) for the fact that , while the CASE-SENSITIVE attribute returns TRUE, the field isn't actually C-S.

When you contact TS you can have them associate your case(s) with that bug.
 
-- peter
 

This thread is closed