help on string comparisons

help on string comparisons

Postby damianodec » Fri Oct 18, 2019 8: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: Select all  Expand view

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 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 414
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: help on string comparisons

Postby Marc Vanzegbroeck » Fri Oct 18, 2019 8:29 am

Can you try with this

Code: Select all  Expand view
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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: help on string comparisons

Postby damianodec » Fri Oct 18, 2019 9: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 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 414
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: help on string comparisons

Postby AntoninoP » 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
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: help on string comparisons

Postby damianodec » Fri Oct 18, 2019 1: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 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 414
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Eroni, FAST WebCrawler [Crawler], Google [Bot] and 58 guests