|
with selected_custs (customer_number) as
Values (123456789) , (234567890), (345678901)
)
select *
from selected_custs S
left outer join customer_master M
on M.customer_number = s.customer_number;
Note you're get two customer_number columns back, the second will be NULL
if the customer isn't found in customer_master
Charles
On Tue, Jul 14, 2020 at 1:48 PM Javier Sanchez <
javiersanchezbarquero@xxxxxxxxx> wrote:
Good day everyone.a
I need to update a table whose key is a customer number, say a
NUMERIC(9,0).
I have to search with a cursor, for example like this:
EXEC SQL DECLARE CSR0001 CURSOR FOR
SELECT * FROM CUSTOMER_MASTER WHERE CUSTOMER_NUMBER IN (
123456789,
234567890,
345678901,....)
and assume that it is a literal very large list of customer numbers, say
over 20,000.
I need to do a simple update of a column for some status for each found
row. But I need also to report which row was NOT found in this search in
order to do some other task.
I suspect I should use a MERGE for this, but if I only use this cursor
approach, how does one know which rows are NOT found within the literal
list while the engine is searching?
Is there a kind of "exit" event to capture when the engine DOES NOT find
matching row?--
Thanks in advance.
JS
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.