Page 1 of 1

help on string comparisons

Posted: Fri Oct 18, 2019 8:02 am
by damianodec
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

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?

Re: help on string comparisons

Posted: Fri Oct 18, 2019 8:29 am
by Marc Vanzegbroeck
Can you try with this

Code: Select all

cCdpar = "45224366010"
IF !alltrim(oRs:Fields("CODICE"):value) == alltrim(cCdpar)
    cCdpar = oLgoft:Fields("LGCDPA"):value
endif
 

Re: help on string comparisons

Posted: Fri Oct 18, 2019 9:13 am
by damianodec
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 ?

Re: help on string comparisons

Posted: Fri Oct 18, 2019 10:38 am
by AntoninoP
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

Re: help on string comparisons

Posted: Fri Oct 18, 2019 1:06 pm
by damianodec
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".