View previous topic :: View next topic |
Author |
Message |
sri50131 Beginner
Joined: 07 Oct 2004 Posts: 38 Topics: 15
|
Posted: Wed Sep 13, 2006 12:56 pm Post subject: using like for a host variable |
|
|
Hello,
I am executing the following query in my Cobol pgm;
EXEC SQL
SELECT I_CONTROL, I_SYMBOL
INTO :WS-I-CONTROL, :WS-I-SYMBOL
FROM PAST0170_MASTER
WHERE N_MFG = :WS-VEH-MAKE
AND I_MODEL LIKE RTRIM(:WS-VEH-MODEL) || '%'
AND D_YEAR = :WS-VEH-YEAR
END-EXEC
This is the first time that I ever had to use like in an embedded SQL. The DB2 column I_MODEL has a length of X(61). WS-VEH-MODEL is defined as X(26), this is the Max length that WS-VEH-MODEL can receive.
When I execute the pgm, I am getting SQLCODE = +100. Am I doing anything wrong? Please let me know.
Thanks |
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed Sep 13, 2006 3:46 pm Post subject: |
|
|
Try making WS-VEH-MODEL X(61) and replace trailing spaces with '%'. |
|
Back to top |
|
 |
sri50131 Beginner
Joined: 07 Oct 2004 Posts: 38 Topics: 15
|
Posted: Wed Sep 13, 2006 4:43 pm Post subject: |
|
|
Bithead, I tried it and still am getting a +100. |
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Thu Sep 14, 2006 8:44 am Post subject: |
|
|
Sri50131,
Make sure that all trailing spaces are converted to %. |
|
Back to top |
|
 |
|
|