NetTalk Central

Author Topic: Problem with Locator and descending sort  (Read 2917 times)

Matthew

  • Full Member
  • ***
  • Posts: 137
    • View Profile
    • Email
Problem with Locator and descending sort
« on: January 31, 2012, 11:26:51 PM »
Hello

I have a browser based on view of two tables and locator. When I sort descending on the integer field from secondary related file and tipe for example, number 123, the procedure NetWebServerWorker._SetView treats this field as a string and adds to the where condition clause 'upper(field)<= '123z'.
SQL returns an error and the browser becomes a blank. The problem is in the following routine (the field is searched only in the primer table – netweb.clw).

Quote
FindField     Routine
 DATA
loc:fields    long
 CODE
 If p_Field = '' then exit.
 compile('***',_VER_C55)
  ! Clarion 5.5 or above only !
  loc:record &= p_File{prop:record}
  loc:fields = p_File{prop:fields}
  loop x = 1 to loc:fields
   ! p_field is the label not the name of the field.
   if clip(upper(p_File{prop:label,x})) = clip(upper(p_Field))
    loc:field &= What(loc:record,x)
    Loc:FieldLabel = self._SetLabel(p_File,x)
    !do SetLabel
    case(p_File{prop:type,x})
    of 'LONG' orof 'ULONG' orof 'DECIMAL' orof 'PDECIMAL' orof 'BYTE' orof 'SHORT' orof 'USHORT' orof 'REAL' orof 'SREAL' orof 'DATE' orof 'TIME'
     loc:numeric = 1
    else
     loc:numeric = 0
    end
    break
   End
  end

Searching through all the view tables solves my problem:
(font-weight: bold are my changes)

FindField     Routine
 DATA
loc:fields    long
FileRef      &FILE
 CODE
 If p_Field = '' then exit.
 compile('***',_VER_C55)
  ! Clarion 5.5 or above only !
!p_View
  LOOP ii# = 1 TO p_View{PROP:Files}
    FileRef &= p_View{PROP:File, ii#}


loc:record &= FileRef{prop:record}
loc:fields = FileRef{prop:fields}
loop x = 1 to loc:fields
 ! p_field is the label not the name of the field.
 if clip(upper(FileRef{prop:label,x})) = clip(upper(p_Field))
loc:field &= What(loc:record,x)
Loc:FieldLabel = self._SetLabel(FileRef,x)
!do SetLabel
case(FileRef{prop:type,x})
of 'LONG' orof 'ULONG' orof 'DECIMAL' orof 'PDECIMAL' orof 'BYTE' orof 'SHORT' orof 'USHORT' orof 'REAL' orof 'SREAL' orof 'DATE' orof 'TIME'
 loc:numeric = 1
else
 loc:numeric = 0
end
break
 End
end

Besides, added character 'z' in polish language is not the last in the alphabet, which is letter “ż” Maybe it could be read from the file environment (environment variable CLACOLSEQ - .env)

Regards,
Matthew

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Problem with Locator and descending sort
« Reply #1 on: January 31, 2012, 11:51:02 PM »
thanks for the code Matthew. I'll see what I can do to get that folded in.

BTW - sorting on a secondary field in a VIEW works, but it can be _very_ slow (depending on the size of the result set). So I usually turn off column sorting for secondary fields. Nevertheless it should work, so your code is good.

>> Besides, added character 'z' in polish language is not the last in the alphabet, which is letter “ż” Maybe it could be read from the file environment (environment variable CLACOLSEQ - .env)

ahh, the joys of working with various back-ends, and various character sets, and so on. There are complications here when it comes to "working everywhere" - but I take the point that some sort of control is necessary for you. I'll see what can be done about that.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Problem with Locator and descending sort
« Reply #2 on: February 01, 2012, 01:49:51 AM »
I've tweaked the code in SetView along the lines of what you suggested for the 6.18 build. Thanks.