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: 1278
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 Join in SQL Query vickey_dw DB2 0 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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