Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Query on Identity column

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
krithikaj

New User


Joined: 10 Aug 2008
Posts: 45
Location: India

PostPosted: Wed Dec 15, 2010 9:15 pm    Post subject: Query on Identity column
Reply with quote

Hi,

I have a table where the Pkey is defined as identity column (GENERATED BY DEFAULT BY IDENTITY).

I am using this table in one of the SELECT cursors in my COBOL-CICS-DB2 program. I send the value as -1 for this coumn in my input to the program. My question here is, before I insert a row, I have a select query in which I am joining this table on this identity column. What would be the value that would be considered and the possible SQLCODE of the cursor?

Thanks
K J
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Dec 15, 2010 9:35 pm    Post subject:
Reply with quote

Hello,

If you set a value to -1, the value will be -1 . . . (unless you are possibly talking about a null indicator). . .

I have no idea what this means - maybe clarification can be provided:
Quote:
What would be the value that would be considered and the possible SQLCODE of the cursor?
Back to top
View user's profile Send private message
krithikaj

New User


Joined: 10 Aug 2008
Posts: 45
Location: India

PostPosted: Wed Dec 15, 2010 9:45 pm    Post subject: Reply to: Query on Identity column
Reply with quote

Hi Dick,

I have table name ITEM where ITEM_ID is defined as GENERATED BY DEFAULT AS IDENTITY.

Now i have COB-CICS-DB2 program PGM1 for which the INPUT-COPYBOOK has value for ITEM_ID = -1. In the program, I have a CURSOR1 which performs SELECT function say like this..

SELECT A.COL1, B.COL2, C.COL3
FROM A
LEFT OUTER JOIN B ON
A.COL3 = B.COL3
LEFT OUTER JOIN ON
A.COL2. C.COL2
LEFT OUTER JOIN ON ITEM D ON
B.ITEM_ID = -1 (VALUE FROM INPUT_COPYBOOK)

Then, I would like to know whether what would be the value for SQLCODE when this cursor is fetched as the ITEM_ID in table cannot be -1.

Thanks,
K J
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Dec 16, 2010 12:15 am    Post subject:
Reply with quote

Hello,

Suggest you post the actual sql using the real table and column names rather than the alphabet soup that provides little continuity.

What happens when you run the query on your system?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Dec 16, 2010 3:40 pm    Post subject:
Reply with quote

-1 is a valid value for an identity column.
This would work just like if the variable contained f.e. 913467
Back to top
View user's profile Send private message
krithikaj

New User


Joined: 10 Aug 2008
Posts: 45
Location: India

PostPosted: Wed Dec 22, 2010 4:57 am    Post subject: Reply to: Query on Identity column
Reply with quote

Thanks a lot for reply.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us