If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How many rows loaded ??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-10, 21:33
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
How many rows loaded ??

Hi ,

Any idea how can I get num_rows loaded in the target table.

Code:
call admin_cmd('load from (select * from T1 fetch first 400 rows only) of cursor insert into T2 nonrecoverable');

select ROWS_LOADED into v_num_rows from table( admin_get_msgs(operation_id) as msg);
Can some one correct me. I do not know how to find operation_id

regards

DBFinder
Reply With Quote
  #2 (permalink)  
Old 02-13-10, 14:54
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Have a look at the usage notes

IBM DB2 9.7 for Linux, UNIX and Windows Information Center


Quote:
Originally Posted by DBFinder View Post
Hi ,

Any idea how can I get num_rows loaded in the target table.

Code:
call admin_cmd('load from (select * from T1 fetch first 400 rows only) of cursor insert into T2 nonrecoverable');

select ROWS_LOADED into v_num_rows from table( admin_get_msgs(operation_id) as msg);
Can some one correct me. I do not know how to find operation_id

regards

DBFinder
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 02-13-10, 18:15
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Had a look at that few times

Quote:
Usage notes
The query statement that invokes this table function with the appropriate operation_id can be found in the MSG_RETRIEVAL column of the first result set returned by the ADMIN_CMD procedure.
Can some one give me example how a can I retrieve First Result Set to obtain operation_id


Regards

DBFinder
Reply With Quote
  #4 (permalink)  
Old 02-14-10, 07:03
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Reading your orignal post again, if all you want is the number of rows loaded, then you can use rows_loaded in the result set ...

But if you want more information, say, when you get an error etc, then use MESSAGES ON SERVER clause in the load command.

here is an example

Code:
 
db2 "call admin_cmd('load from (select * from t10) of cursor messages on server  insert into t1 nonrecoverable')"
 
 Result set 1
 --------------
 ROWS_READ            ROWS_SKIPPED         ROWS_LOADED          ROWS_REJECTED        ROWS_DELETED         ROWS_COMMITTED       ROWS_PARTITIONED     NUM_AGENTINFO_ENTRIES MSG_RETRIEVAL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    MSG_REMOVAL                                                                                                                                                                                                                                                                                                                                                                                                                    
 -------------------- -------------------- -------------------- -------------------- -------------------- -------------------- -------------------- --------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
               449596                    0               449596                    0                    0               449596                    -                     - SELECT SQLCODE, MSG FROM TABLE(SYSPROC.ADMIN_GET_MSGS('1389781381_DB2INST1')) AS MSG                                                                                                                                                                                                                                                                                                                                                                                                                                             CALL SYSPROC.ADMIN_REMOVE_MSGS('1389781381_DB2INST1')                                                                                                                                                                                                                                                                                                                                                                          
 1 record(s) selected.
 Return Status = 0
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 02-14-10, 10:45
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Well,

I need to use ADMIN_CMD in Stored Procedure.
Where I get operation_id to retrive result set 1 ??.


rgds
DBFinder
Reply With Quote
  #6 (permalink)  
Old 02-15-10, 19:46
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
duplicate answer
Reply With Quote
  #7 (permalink)  
Old 02-15-10, 19:57
DB2Plus DB2Plus is offline
Registered User
 
Join Date: Jul 2009
Posts: 150
Smile

Quote:
Originally Posted by db2girl View Post
duplicate answer
Oh, girl !
(Beatles)
Reply With Quote
  #8 (permalink)  
Old 02-15-10, 20:33
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
My original response was a duplicate of sathyaram_s's so I removed it...

See if this is something you can use:


more test_adm
Code:
create procedure test_adm(
out p_rows_exp BIGINT,
out p_msg_retreive VARCHAR(512),
out p_msg_remove VARCHAR(512))
specific test_adm
language SQL

BEGIN
DECLARE cmdline VARCHAR(1024);
DECLARE v_msg_retreival VARCHAR(512);
DECLARE v_rows_exp bigint;
DECLARE v_msg_removal VARCHAR(512);
DECLARE v_admin_cmd_str VARCHAR(512);
DECLARE result1 RESULT_SET_LOCATOR VARYING;

CALL sysproc.admin_cmd('export to /home/bkogan/testadm of del messages on server select * from test');

ASSOCIATE RESULT SET LOCATORS(result1) WITH PROCEDURE sysproc.ADMIN_CMD;
ALLOCATE rsCur CURSOR FOR RESULT SET result1;
FETCH rsCur INTO v_rows_exp, v_msg_retreival, v_msg_removal;
SET p_rows_exp = v_rows_exp;
SET p_msg_retreive = v_msg_retreival;
SET p_msg_remove = v_msg_removal;

END
@


db2 -td@ -f test_adm
DB20000I The SQL command completed successfully.


db2 "call bkogan.test_adm(?,?,?)"

Value of output parameters
--------------------------
Parameter Name : P_ROWS_EXP
Parameter Value : 2

Parameter Name : P_MSG_RETREIVE
Parameter Value : SELECT SQLCODE, MSG FROM TABLE(SYSPROC.ADMIN_GET_MSGS('2480_BKOGAN')) AS MSG

Parameter Name : P_MSG_REMOVE
Parameter Value : CALL SYSPROC.ADMIN_REMOVE_MSGS('2480_BKOGAN')

Return Status = 0

Last edited by sathyaram_s; 03-26-10 at 08:10. Reason: added code tag
Reply With Quote
  #9 (permalink)  
Old 02-16-10, 06:36
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Thanks Bella,

This was something I was looking for long time.
I am sure this will fulfil my immediate need.
I hope you won't mind posting any shortcut for more details on this for me.

Tons of regard for everyone

DBFinder

Last edited by DBFinder; 02-16-10 at 09:09.
Reply With Quote
  #10 (permalink)  
Old 02-16-10, 18:50
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Sorry, I don't have any additional information
Reply With Quote
  #11 (permalink)  
Old 02-16-10, 18:56
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
NP


DBFinder
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On