473,748 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MERGE and GET DIAGNOSTICS ROW_COUNT

row_count - is it total inserted,update d or deleted by merge statement?
Any way get different counts?

Andy

Nov 12 '05 #1
1 3148
bughunter@ru wrote:
row_count - is it total inserted,update d or deleted by merge statement?
Any way get different counts?

Andy

Good one... we pondered this question quite a bit.
http://publib.boulder.ibm.com/infoce...6c%63%61%22%20
"After INSERT, UPDATE, DELETE, or MERGE, contains the actual number of
rows that qualified for the operation."
The rows "qualifying for MERGE" are all the rows which don't hit the
"ELSE IGNORE" section. That is, it is the sum of all rows processed by
each WHEN [NOT] MATCHED branch.

The owrds were chosen thinking about INSTEAD OF trigger where rowcount
could be any value, yet the insert trigger just dumped the rows to
nirwana or did all sorts of complex stuff.

Eventually I'd like to see this:
SELECT COUNT(*) cnt, mode FROM
NEW TABLE(MERGE INTO T INCLUDE (mode VARCHAR(10)
USING S ON T.pk = S.pk
WHEN MATCHED THEN UPDATE SET c1 = S.c1,
mode = 'UPDATE'
WHEN NOT MATCHED THEN INSERT VALUES (pk, c1, 'INSERT'))
GROUP BY mode;

*Thinking of my happy-place with infinite resources*
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2143
by: Slava Gorski | last post by:
Hi all, It seems that get diagnostics is not supported by ecpg in postgresql 7.3, I always get the following error when trying to use it: ERROR: parse error at or near "diagnostics" For example, the following code does not compile: #include <stdio.h>
1
2556
by: - | last post by:
i have a stored procedure consisting of several delete statements and i want to be able to return the "Query OK, 0 rows affected" such that the total number of rows deleted are summed up rather than returning the number of affected rows of the last statement. the number of rows deleted can be obtained through the ROW_COUNT() and i can add it up. but how do i set the value of the "Query OK, XXX rows affected"?
2
4848
by: N.V.Dev | last post by:
Hi, I am trying to use GET DIAGNOSTICS statement after an INSERT. DB2 does not return the # of rows inserted. Below is the code and output. ----Code snippet DROP PROCEDURE DIAG_CHECK @ CREATE PROCEDURE DIAG_CHECK ()
3
2542
by: Rhino | last post by:
I just stumbled on something odd but I'm not sure if it's a bug in DB2 or something that is "working as designed." I have a simple SQL PL stored procedure which is doing an "INSERT SELECT..." (as opposed to an "INSERT... VALUES ...") and I'm doing a GET DIAGNOSTICS after the insert to ensure that the expected number of rows was inserted. However, GET DIAGNOSTICS is reporting that 0 rows were inserted, regardless of the SELECT that I use...
8
9523
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for each person for whom a mail merge letter is desired. The query reads address info from the table for each record where is true.
3
5586
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
4
7065
by: kenfar | last post by:
I've got a batch etl process in which I typically wrap DML with selects in order to capture the number of rows affected. For example: SELECT 'rows updated', COUNT(*) FROM NEW TABLE ( UPDATE stage_asset SET ip_int = ip_to_bigint(ip_string) WHERE ip_int IS NULL ) How can I do this for a merge? For example:
2
1638
by: fniles | last post by:
I am using VS 2005. When building a "Setup and Deployment" project, how can I copy and merge registry settings to the user's machine ? The registry setting is in HKEY_CURRENT_USER/Software/VB and VBA Program Settings. Thank you.
1
2558
by: sriramyait | last post by:
create procedure sam() language sql BEGIN declare numrows integer default 0; update sri set id=95 where id =99; commit; GET DIAGNOSTICS numrows = ROW_COUNT; UPDATE sri1 SET id =numrows WHERE id =0; commit; END
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.