IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting a -401 SQL code


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Thu Mar 22, 2007 8:51 pm
Reply with quote

Hi,

In a SQL query, Iam using the following predicate in the 'WHERE' clause:

Code:

OR  (SUBSTR (GN_TXN_DATA,191,15)               
                          = :D011-IWA-AMT-1)



As per the rule, scalar function SUBSTRING always returns the data in character format. The host variable D011-IWA-AMT-1 has been defined as X(15). But when I bind the module, it gives me a SQL CODE -401 which is "THE OPERANDS OF AN ARITHMETIC OR COMPARISON OPERATION ARE NOT COMPARABLE".

Could someone please tell me where am going wrong !!!
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Thu Mar 22, 2007 9:17 pm
Reply with quote

I'm not so sure about cobol firstly.
I believe X(15) declaration should be changed to A(15).
I might be wrong since am very bad in COBOL.
Can you paste the entire query and the declaration of :D011-IWA-AMT-1.

Are you sure your bind is failing @ this query..?
Can you paste the bind error message.
Back to top
View user's profile Send private message
girias

New User


Joined: 09 Feb 2007
Posts: 26
Location: Chennai

PostPosted: Tue May 29, 2007 5:23 pm
Reply with quote

Hi,
I too got the same error. Can any one help me out.

Let us take the above scenario itself.
I tried giving it as 9(15). But I am getting compilation error saying

Code:
"SQL host variable had invalid syntax or the referenced host variable was an invalid SQL variable type.  The statement was discarded."


Thanks
Giri
Back to top
View user's profile Send private message
munikumar
Currently Banned

New User


Joined: 18 Apr 2007
Posts: 24
Location: India

PostPosted: Thu Jun 07, 2007 11:48 am
Reply with quote

Try this,

OR CHAR((SUBSTR (GN_TXN_DATA,191,15))
= :D011-IWA-AMT-1)

I have not checked this.
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Thu Jun 07, 2007 3:37 pm
Reply with quote

use this---

(SUBSTR (CHAR(GN_TXN_DATA),191,15)
= :D011-IWA-AMT-1)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Monitoring production job progress. N... JCL & VSAM 4
Search our Forums:

Back to Top