Ingest Utility with delete statement in db2 doesnt show number of rows deleted - db2

When I run the ingest utility with the delete statement it gives the number of rows inserted as 0 and doesn't show the number of rows deleted. Is there any option to show the number of rows deleted?
I have included the output message of the ingest utility and the code
output
------
Number of rows read = 255
Number of rows inserted = 0
Number of rows rejected = 0
code
----
db2 "ingest from file mypipe format delimited(
$field1 CHAR(9),
$field2 DATE 'yyyy-mm-dd'
)
Delete from mytable where dob = $field2"

The documentation specifies initially that the summary report only contains the number of rows read, inserted , rejected. This is perhaps what you are seeing.
Quote from documentation:
Messages from the INGEST command If the utility read at least one
record from the input source, the utility issues a summary of the
number of rows read, inserted, and rejected (similar to the import and
load utilities) and a successful completion message.
However, on the same page a later statement is:
Number of rows inserted (updated, deleted, merged)
The number of rows affected by the execution of the SQL statement against the target table and committed to the database. The message
says "inserted", "updated", "deleted", or "merged", depending on the
SQL statement.
So the behaviour for your case seems unhelpful, and IBM could make it better by additionally including the count of rows deleted, and count of rows updated when the sole SQL statement is DELETE. I tested this behaviour with Db2-LUW v11.5.6.0".
Even when the delete statement is replaced by a MERGE with WHEN MATCHED THEN DELETE the summary report excludes the count of deleted rows. Undesirable behaviour.
If you have a support contract, you could open a ticket with IBM asking for a workaround or fix as there may be some regression here.

Related

Power BI Or SQL function for iterating through rows, finding null in cell and then deleting all rows with same identifier

I am trying to find the best way to clean my data using either T-SQL or a tool within Power BI.
included is a snippet of my data, I would usually do this in Excel using multiple tables & VLOOKUP however my data set contains 2+ million Rows so this isn't an option.
I need a function that:
Iterates through each row looking at each 'SiteID'
checks related 'flow' value for 'NULL' or '0'
If 'NULL' or '0' finds all the rest of the 'SiteID's' with the same value in the full data set in the rows above or below
Removes all rows with matching 'ID'S' Regardless if any other 'null' or actual value exists
Moves onto next record checking same & continuing iteration of complete data set
is this something which is possible? thanks for any advice or help :)
Sample data values
I want to add another thing, if you have a million rows of data, iteration is not a good option to think about. I guess all you want is to remove records having Null or 0 in flow. I perfer to use CTE just to be clear in logic.
;WITH deletion AS
(
SELECT SiteID
FROM Table1
WHERE Flow = 0 or Flow is null
)
DELETE T
FROM Table1 T
INNER JOIN Deletion D on T.SiteID = D.SIteID

IBM Datastage : Creating column that is calculation

I have a table which columns are location and credit, the location contains string rows which mainly is location_name and npl_of_location_name. the credit contains integer rows which mainly is credit_of_location_name and credit_npl_of_location_name. I need to make a column which calculates the ((odd rows of the credit - the even rows of the credit)*0.1). How do i do this?
When you specify "odd rows" and "even rows" are you referring to row numbers? Because, unless your query sorts the data, you have not control over row order; the database server returns rows however they are physically stored.
Once you are sure that your rows are properly sorted, then you can use a technique such as Mod(#INROWNUM,2) = 1 to determine "odd" and zero is even. This works best if the Transformer is executing in sequential mode; if it is executed in parallel mode then you need to use a partitioning algorithm that ensures that the odd and even rows for a particular location are in the same node.

long running queries and new data

I'm looking at a postgres system with tables containing 10 or 100's of millions of rows, and being fed at a rate of a few rows per second.
I need to do some processing on the rows of these tables, so I plan to run some simple select queries: select * with a where clause based on a range (each row contains a timestamp, that's what I'll work with for ranges). It may be a "closed range", with a start and an end I know are contained in the table, and I know no new data will fall into the range, or an open range : ie one of the range boundary might not be "in the table yet" and rows being fed in the table might thus fall in that range.
Since the response will itself contains millions of rows, and the processing per row can take some time (10s of ms) I'm fully aware I'll use a cursor and fetch, say, a few 1000 rows at a time. My question is:
If I run an "open range" query: will I only get the result as it was when I started the query, or will new rows being inserted in the table that fall in the range while I run my fetch show up ?
(I tend to think that no I won't see new rows, but I'd like a confirmation...)
updated
It should not happen under any isolation level:
https://www.postgresql.org/docs/current/static/transaction-iso.html
but Postgres insures it only in Serializable isolation
Well, I think when you make a query, that means you create a new transaction and it will not receive/update data from any other transaction until it commit.
So, basically "you only get the result as it was when you started the query"

Count rows in massive .csv file

dumping a Postgres table out by sections is yielding sections that are 30GB+ in size. The files are landing on a windows 2008 server. I'm trying to count the rows in the csv to ensure I have a row count that I expect (22,725,303 to be exact). I can count the rows in the section that I expect to dump - but I am not sure if I'm getting them all.
It's a 190M row table so sections of table is the way to go.
so how can I count the rows so I know I've got the full section?
In a PL/pgSQL function, you can get the count of rows processed by the last command - since Postgres 9.3 including COPY - with:
GET DIAGNOSTICS x = ROW_COUNT;
Get the count of rows from a COPY command

See length (count) of query results in workbench

I just started using MySQL Workbench (6.1). The default limit for queries is 1,000 and that's fine I want to keep that.
But the results from the action output message will therefore always say "1000 rows returned".
Is there a setting to see the number of records that would be returned in the query had their been no limit? For sanity checking query results?
I know this is late by a few years, but I think you're asking for a way to see total row count in the bottom of the results pane, like in SQL Server. In SQL Server, you would also go in the messages pane and it would say how many rows were returned. I was actually looking for exactly what you were asking for as well, and seems like there is no way to find that. If you have an ID in your table that is just numeric and is in numeric order, you could order by ID desc and look at the biggest number there. That is what I've decided to do.
The result is not always "1000 rows returned". If there are less records than that you will get the actual count. If you want to know the total number of rows in a table do a select count(*) from table. Alternatively, you can switch off the automatic limit and have all records returned by MySQL Workbench, but that can be time + memory consuming for large tables.
I think removing the row limit will help. By default, MySQL workbench will limit the result set to 1000 rows but you can always disable the limit. Check out https://superuser.com/questions/240291/how-to-remove-1000-row-limit-in-mysql-workbench-queries on how to do that.
You can run a second query to check that
select count(*) from (your original query) as t;
this will return the total rows in actual result.
You can use the SQL count function. It returns the count of the total number of rows a query returns.
A sample query:
select count(*) from tableName where field1 = value1
In workbench, in the dropdown menu at the top, set it to dont limit Then run the query to extract data from table Then under the output pane below, the total count of the query results will be displayed in the message column