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

Multi-rows insert and a number of a bad record


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

New User


Joined: 15 Nov 2011
Posts: 4
Location: Belarus

PostPosted: Tue Nov 15, 2011 9:41 pm
Reply with quote

Hi.
I'm using multi-rows insert in a C-program. The program reads a file, populates SQLDATA arrays and executes insert. Because of bad data in the file DB2 fails insert. Is it possible to get a number of a bad record in the array/file? Thanks in advance.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Nov 15, 2011 9:51 pm
Reply with quote

It even provides the code :Checking the execution of SQL statements by using the GET DIAGNOSTICS statement
Back to top
View user's profile Send private message
Vladimir Mestovski

New User


Joined: 15 Nov 2011
Posts: 4
Location: Belarus

PostPosted: Wed Nov 16, 2011 2:06 pm
Reply with quote

Thank you very much GuyC, the DB2_ROW_NUMBER is exactly what I need.

I'm creating a program that combines almost all features of DSNTEP4, DSNTIAUL, LOAD utility, QMF style of a SELECT report, and more...
Don't know if similar program already exists...Here is an output of the program:
*** SQLMON - Batch SQL Monitor *** (built on Nov 16 2011 02:00:05 by VM)
*** CURRENT TIMESTAMP = 2011-11-16-02.58.16.044467
*** Used parameters:
INSQL(DD:SYSIN)
TAGS()
OUTSQL()
CONNECT TO BYDB2LAB;
*** CONNECT successful, SERVER_NAME='BYDB2LAB'
WRITE CSV FILE DD:DSN1 SELECT * FROM CPEOUTT.TIM_OVG_CLASS WITH UR;
*** Successful WRITE of 134355 record(s), RECFM=FB, LRECL=194
*** CPU time = 1.3602 seconds, TOTAL time = 4 seconds

CONNECT TO BYDB2LABE;
*** CONNECT successful, SERVER_NAME='BYDB2LABE'
DECLARE GLOBAL TEMPORARY TABLE SESSION.TIM_OVG_CLASS
LIKE CPEOUT.TIM_OVG_CLASS;
*** DECLARE successful
*** CPU time = 0.0056 seconds, TOTAL time = 0 seconds
READ CSV FILE DD:DSN1 INSERT INTO SESSION.TIM_OVG_CLASS VALUES(*);
*** VALUES(1.14,16.14,31.10,42.11,54.10,65.11,77.10,88.11,100.10,111.11,123.10,
*** Successful READ & INSERT of 134355 row(s)
*** CPU time = 2.4608 seconds, TOTAL time = 5 seconds
CREATE INDEX SESSION.I1 ON SESSION.TIM_OVG_CLASS (STAGE_PN);
*** CREATE successful
*** CPU time = 0.4951 seconds, TOTAL time = 2 seconds

EXPLAIN SELECT * FROM SESSION.TIM_OVG_CLASS WHERE STAGE_PN LIKE '00%';
+------+-----+------+-----+------+------+-----+------+-----+-------+------------
|PARENT|QUERY| QUERY| | | |USED | | | |
|QBLOCK|BLOCK| BLOCK|RUN |JOIN |ACCESS|INDEX|TABLE |TABLE| TABLE | TABLE
|NO |NO | TYPE |ORDER|METHOD|TYPE |COLS |NUMBER|TYPE | OWNER | NAME
+------+-----+------+-----+------+------+-----+------+-----+-------+------------
| 0 | 1 |SELECT| 1 | 0 | I | 1 | 1 | T |SESSION|TIM_OVG_CLAS
+------+-----+------+-----+------+------+-----+------+-----+-------+------------
*** Successful retrieval of 1 row(s)
*** CPU time = 0.0004 seconds, TOTAL time = 0 seconds
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top