View previous topic :: View next topic
|
Author |
Message |
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
Can you do a wild card search in IMS? similar to WHERE SEARCHTERM LIKE %123% in DB2? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
You mean while browsing IMS DB using IMS File-Aid or...? |
|
Back to top |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
while querying an IMS database from a COBOL program using a qualified SSA |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
You are possibly talking about a generic search - providing a partial key to position before the first segment matching that partial key and then doing a GN to retrieve the actual segment and continuing until you get the segment that you want. Yes/No? |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
It's more tricky than SQL. It also depends on the structure of the database, or if it has an index. Also if the keys are unique or non-unique.
You can do a leading match, (LIKE 123%) but not a middle match (LIKE %123%). But only with an index or a HIDAM. If you try it with an HDAM, you will probably not get what you want.
One thing to remember is that an SSA starts over with each Boolean OR. So
A>0 and B=1 or B=2 won't work right. you need to repeat some things
A>0 and B=1 or A>0 and B=2.
Tell us if you're talking about key fields or search fields. |
|
Back to top |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
There are 2 fields in the database I want to perform a wildcard search with. One is Indexed and one is not.
I am new to IMS so you may have to spell it out for me. When you say you can do LIKE, do you mean that instead of EQ, GE, LE, etc in the SSA, if is possible to say like? So, is the below a valid SSA?
Code: |
01 OIPSSSA1.
05 OISPD001-SSA PIC X(8) VALUE 'DBNAMEXX'.
05 OI1-SEG-QUAL-1 PIC X(1) VALUE '('.
05 OI1-SEG-NAME-1 PIC X(8) VALUE 'KEYNOXXX '.
05 OI1-OP-CODE-1 PIC X(2) VALUE 'LIKE'.
05 OI1-KEY-VALUE-1 PIC 9(11) VALUE ZEROES.
05 OI1-END-QUAL-1 PIC X(1) VALUE ')'.
|
then I can move 123% to OI1-KEY-VALUE-1? |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Nope, you'll need to use the usual SSA operators. Can you give me the segment name, field names and their definitions?
It will look more like this:
Code: |
DBNAMEXX*---(KEYNOXXXGE00000000000) |
with two fields:
Code: |
DBNAMEXX*---(KEYNOXXXGE00000000123*OTHERKEYEQVALUE2) |
|
|
Back to top |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
what is OTHERKEYEQVALUE2? I don't have a second key value... |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
This was because you said
Quote: |
There are 2 fields in the database I want to perform a wildcard search with |
|
|
Back to top |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
oh sorry! I think I am having trouble understanding how GE (which is Greater than or equal to) works as a LIKE statement.
A LIKE statement looks for anything matching a pattern you give it. Greater Than, to me, implies the comparison against a number. These are two completely different things.
Let's say that I am wanting to query an IMS database for a Customer Number that is alpha-numeric and I only have 3 customers. They are
A12B456
B34T567
R76N000
now if I can say LIKE A12% I should get back A12B456
but if I am saying GE A12.... what am I going to get? |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Ah...
You would get all of them, because they are all GE your query.
You would have to say
Code: |
DBNAMEXX*---(KEYNOXXXGEA12....*KEYNOXXXLEA12????)
|
where .... is low values and ???? is high values. This works really well if the KEYNOXXX is the single index field. It still works if the database is HIDAM and this is the primary key. If the database is HDAM, it won't really work if you're going against the database directly (not through an index). |
|
Back to top |
|
|
|