FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour help on string comparisons
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
help on string comparisons
Posted: Fri Oct 18, 2019 08:02 AM
Hi
I have this field in recordset: oRs:Fields("CODICE"):value
Field CODICE in table is CHAR(15) but in oRs object it lost right blanks.
inside table I have due article:
1st article "5224366010"
2nd article "5224366010V10"

when field oRs:Fields("CODICE"):value is "5224366010V10"
Code (fw): Select all Collapse
cCdpar = "45224366010"
IF oRs:Fields("CODICE"):value <> cCdpar
    cCdpar = oLgoft:Fields("LGCDPA"):value
endif


the IF istruction is false but articles are diferrent.

how can I to solve it? have I to use SET EXACT ON?
FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: help on string comparisons
Posted: Fri Oct 18, 2019 08:29 AM
Can you try with this

Code (fw): Select all Collapse
cCdpar = "45224366010"
IF !alltrim(oRs:Fields("CODICE"):value) == alltrim(cCdpar)
    cCdpar = oLgoft:Fields("LGCDPA"):value
endif
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: help on string comparisons
Posted: Fri Oct 18, 2019 09:13 AM

hi Marc, thank you, that's good solution.
But is SET EXACT ON a good solution too?

why CHAR fields in recordest lose right blanks ?

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: help on string comparisons
Posted: Fri Oct 18, 2019 10:38 AM

which database are you using? the column is char(15) or varchar(15)?
On our application on SQL Server we have all column "char" and the spaces are not trimmed.
they are trimmed with varchar

Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: help on string comparisons
Posted: Fri Oct 18, 2019 01:06 PM

Hi Antonino
Database is BD2 on iSeries IBM and field CODICE is CHAR(15) (not VARCHAR) but when recordset read table chars are trimmed:
Field CHAR(15) in DBU = "123456abc "
field read = "123456abc".

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)

Continue the discussion