Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us