ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SQL "LIKE" not doing what I expect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL "LIKE" not doing what I expect

    I have an SQLRPGLE program in which I am trying to see if a character string exists in a file/field

    Click image for larger version

Name:	RPG01.jpg
Views:	0
Size:	97.7 KB
ID:	144551
    The SQL above returns SQLCODE = 100

    There is clearly a record in the file for which TMAUTH contains ALASKA:
    Click image for larger version

Name:	RPG02.jpg
Views:	0
Size:	42.8 KB
ID:	144548

    This produces SQLCODE = 100, although, doing it interactively returns a row:
    Click image for larger version

Name:	RPG3.JPG
Views:	0
Size:	16.0 KB
ID:	144549

    Click image for larger version

Name:	RPG04.jpg
Views:	0
Size:	22.1 KB
ID:	144550

    I'm guessing there is something really basic I am doing wrong, any ideas?
    Attached Files

  • #2
    Change Somestring to varchar(30) and it will work. The trailing blanks in Somestring are messing you up, as the system is trying to match them to the end of TMAUTH.

    Comment


    • #3
      Originally posted by TedHolt View Post
      Change Somestring to varchar(30) and it will work. The trailing blanks in Somestring are messing you up, as the system is trying to match them to the end of TMAUTH.
      This solved the problem..........thanks again

      Comment

      Working...
      X