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

Insert a Row_number into table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Tue Sep 19, 2017 1:07 pm
Reply with quote

hi,
To avoid the duplicates i have to insert a row_number into the table. could someone please help me achieving this?


EXEC SQL
insert into TBL1
select
request_no,
seq_no,
account_no
into
:host-request-no,
:host-seq_no,---------------------> row_number
:host-account-no
END-EXEC.

I need to populate the seq_no as Row_number in the above Query.please help me in this regard

Regards,
useit
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Sep 19, 2017 1:58 pm
Reply with quote

So you read the highest row number from some control table/data set, add 1 insert the row and update the control data. What is the problem?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Sep 19, 2017 5:34 pm
Reply with quote

Read
www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/sqlref/src/tpc/db2z_sequencereference.html
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top