?
Solved

DB2 [AS/400] Stored Procedure - using LIKE  '%'  in WHERE clause not working

Posted on 2007-04-11
2
Medium Priority
?
1,622 Views
Last Modified: 2009-12-16
Everyone,

The following Stored Proc Selects Data via  cursor, then proceeds to DELETE data from three tables with the same key  - including the same table from which the key originated.

here is my query below:

    DECLARE cursor1 CURSOR FOR  
                select   a.TRTRNO as AuditTranNumber
                   , a.TRRXNO as ClaimNumber
                   , a.TRRXSQ as ClaimSeq
            FROM PSIAUDIT.AUTRAN a
             WHERE IFNULL(a.TRSCOR, 0)   BETWEEN   TRAN_SCORE_FROM   AND   TRAN_SCORE_TO
               AND IFNULL(a.TREDAT, 19000101)   BETWEEN DATE_FROM         AND   DATE_TO
               AND IFNULL(a.TRASNN, '')  LIKE USER_NAME;


Focusing on the last line (LIKE USER_NAME . . .  CHAR(10) b.t.w.)
1)  I pass in '%'  or  'LNAME_FN'  and I get nothing  (no results returned, nothing deleted)

2) When I comment out this line the Stored proc does what it is supposed to do and deletes the data.  (aka. data was returned in the cursor.)

3) i run the above as a SELECT (as-is  except I hard code the params) in iSQL and it returns data.  So something is awry.


So, given the above:
1) What is wrong with this query from a Stored proc perspective?
2) How can I leave in the USER_NAME column in case I want to delete by that icriteria as well as the other column criteria?

thanks for your help
0
Comment
Question by:fshtank
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:fshtank
ID: 18891763
hey Guys,

I solved my problem by converting incoming Parameter  USER_NAME from CHAR(10) to VARCHAR(10).

Question closed.
0
 

Accepted Solution

by:
EE_AutoDeleter earned 0 total points
ID: 19040157
fshtank,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question