View previous topic :: View next topic
|
Author |
Message |
nightbuzzz
New User
Joined: 04 May 2007 Posts: 21 Location: kuala lumpur
|
|
|
|
Hi,
I have a query.....
there is a variable ws-ust1 pic X(20) value 'asdfgh'.
i defined a literal as Lit-percent pic X(1) value '%'.
My concern is I want to run a query using WS-UST1 with 'LIKE' clause.
How should i concatenate the '%' symbol prefixed and suffixed to WS-UST1.
ALSO
wuery will be something like
Select count(*)
into :ws-count
from table1 where column like ws-ust1
I tried using STRING with DELIMITED BY ' ' and DELIMITED BY SIZE but the output string only contains all '%%%%%'.
eg i tried
STRING LT-PERCENT WS-UST1 LT-PERCENT
DELIMITED BY ' ' INTO WS-UST1 .
Please help
Thanks in advance. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Make the output field of the STRING be a separate field (i.e. ust2), not the ust1 field. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The Manual wrote: |
If identifier-1 or identifier-2 occupies the same storage area as identifier-3 or identifier-4, undefined results will occur, even if the identifiers are defined by the same data description entry.
|
As Dick says, new ust2. You should move space first to your new ust2, each time, as the STRING does not "space fill" and you will get data left-over data from previous invocations of the string. |
|
Back to top |
|
|
nightbuzzz
New User
Joined: 04 May 2007 Posts: 21 Location: kuala lumpur
|
|
|
|
Thnx guys... |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
a warning:
if you have
Code: |
ws-ust2 pic x(20) value '%asdfgh% '. |
you're column1 like :ws-ust2 will probably not behave as you expect. Because it will only return rows with at least 12 spaces at the end of column1.
you probably want to fill ws-ust2 with '%asdfgh%%%%%%%%%%%%%'
and the easiest way to do that is
Code: |
move all '%' to ws-ust2
string ws-ust1 delimited by ' ' into ws-ust2(2:) |
or
Code: |
string '%' delimited by size
ws-ust1 delimited by ' '
'%%%%%%%%%%%%%%%%%%%%' delimited by size
into ws-ust2 |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good catch
d |
|
Back to top |
|
|
|