|
-
August 17th, 2009, 03:47 PM
#1
Problem with calling LENGTH() using parameters
I am working on a DB2 system and am trying to call LENGTH() using sqlbindparameter on the following SQL command.
Code:
"SELECT COUNT(*) FROM CLAIM_TICKET WHERE ( (LENGTH(BARCODE) = 26 OR LENGTH(BARCODE) = 28) AND LENGTH('?') = 14 ) AND PIN = ?")
but it always returns back 0 rows even when the string that I binding is 14 characters long. I have tried removing the single quotes but then I receive and error. The PIN parameter works fine (tested by hardcoding the string for Length. Should I be using a different function for passing hte string placed into LENGTH?
Thanks.
-
August 17th, 2009, 03:55 PM
#2
Re: Problem with calling LENGTH() using parameters
Although I haven't worked on DB2, but from what I know you cannot pass a field name as a parameter. You need to specify a fieldname in place of ? or maybe build a dynamic SQL.
-
August 18th, 2009, 07:40 AM
#3
Re: Problem with calling LENGTH() using parameters
I tried passing "LENGTH('data')" as the contents of a ? but that failed too. I also haven't found another method call to use to pass the contents of LENGTH.
-
August 18th, 2009, 01:40 PM
#4
Re: Problem with calling LENGTH() using parameters
Well I have never used DB2, so I can't comment much.
-
August 20th, 2009, 09:00 AM
#5
Re: Problem with calling LENGTH() using parameters
I ended up solving the problem. for some bizarre reason I needed to do:
Code:
LENGTH(CONCAT(?,''))
to get it to work. Really weird but it DOES work. I found a remark about CONCAT in the change files for SQLBINDPARAMETER so figured I would give it a try.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|