View previous topic :: View next topic
|
Author |
Message |
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
Hi All
I would be grateful if people here could help me in resolving this issue.
* * * * *
Query Inside a program:
When I am hard coding a value in the query I am getting the sqlcode as 0.
But when I am using the variable “Ws-base-id” in the query I am getting SQLCODE as 100.
EXEC SQL
SELECT X
INTO :WS-TD-X
FROM Tbname
WHERE ACCT_NBR = :WS-BASE-ID
AND PRODUCT_CODE = 95
GROUP BY ACCT_NBR WITH UR
END-EXEC
* * * * *
This variable is not part of the linkage section. Since I am getting this error only for this table, I am wondering if there is something else that I have not taken care of.
Any help would be greatly appreciated.
Thanks
ram |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please post the definition of acct-nbr and :ws-base-id.
How is a value put into :ws-base-id? Are you sure it is being initialized before the query is executed? |
|
Back to top |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
Here's a small description that might help.
WORKING-STORAGE SECTION.
01 WS-MISC.
05 WS-ACCT-ID.
10 WS-FIRM-ID PIC X(03) VALUE SPACES.
10 WS-BRNCH-ID PIC X(05) VALUE SPACES.
10 WS-BASE-ID PIC X(08) VALUE SPACES.
Populating WS-ACCT-ID:
----------------------------
<snip>
READ ABCD-FILE
AT END
SET WS-EOF-Y TO TRUE
NOT AT END
ADD +1 TO WS-READ-COUNT
MOVE C2DUMP-ACCT-ID TO WS-ACCT-ID
END-READ
.
<snip>
* * * * *
Before executing the query, a display statement is used to display the
Bse Id.
Thanks
ram |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what is the dcl gen definition of the column ACCT_NBR? |
|
Back to top |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
The definition is Pic X(08).
Thanks
Ram |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Hi,
Please try to display the value in WS-BASE-ID just before executing the query. I suspect it does not contain the value you need in the where clause.
Hope this helps. |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Sorry Ram, I didn't see your second post |
|
Back to top |
|
|
satheeshkamal
New User
Joined: 09 Jan 2007 Posts: 28 Location: Chennai
|
|
|
|
What is the strucutre for C2DUMP-ACCT-ID ? |
|
Back to top |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
C2DUMP-ACCT-ID: pic x(16)
I am not sure of this: the only reasonable answer could be that there is some problem with the table definition. I could be wrong though.
Please respond if you have any other ideas.
Thanks
Ram |
|
Back to top |
|
|
satheeshkamal
New User
Joined: 09 Jan 2007 Posts: 28 Location: Chennai
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
after creating a table,
even if the generated copybook is not going to be used,
it is a good habit to run a DCLGEN to check if the hand written definitions
of the columns variables agree with those that will be enforced by DB2
this simple action will avoid lots of errors due to definition misunderstandings! |
|
Back to top |
|
|
|