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

Query on Identity column


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Wed Dec 15, 2010 9:35 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Dec 16, 2010 12:15 am
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
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
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 All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts Extract ISPF table column headings CLIST & REXX 2
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 1
No new posts ISPF Table to add a new column TSO/ISPF 1
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
Search our Forums:


Back to Top