|
I'm trying to insert or update a record in a table. I found the MERGE
statement while googling.
The table has manifest# and cnt (qty) and some other fields that don't
matter. Here is my statement. Once I get this to work, I'll replace the
values and the where with variables.
MERGE INTO boxdetwk AS b1
USING (SELECT * from boxdetwk
where manifest = 93000022
) AS b2
ON (b1.manifest = b2.manifest)
WHEN MATCHED THEN
UPDATE SET b1.cnt = b1.cnt + 9999
WHEN NOT MATCHED THEN
INSERT (manifest,cnt)
VALUES (93000022, 1)
When I run this in interactive SQL, I get the below message Row not found
for MERGE. What am I doing wrong? Thank you.
Message ID . . . . . . : SQL0100 Severity . . . . . . . : 00
Message type . . . . . : Information
Message . . . . : Row not found for MERGE.
Cause . . . . . : One of the following conditions has occurred:
-- If this is a FETCH statement, no more rows satisfy the selection
values
(end of file). The name of the cursor is MERGE and the result set
identifier is 0. If the result set identifier is non-zero, the result
table
for this cursor was being accessed as a stored procedure result set.
-- If this is a FETCH statement for a scrollable cursor, a record was
not
found. If NEXT was specified, end of file was reached. If PRIOR was
specified, the beginning of the file was reached. If RELATIVE was
specified, either the beginning of file or the end of file was reached,
depending on the value specified. If FIRST or LAST was specified, then
no
records satisfy the selection criteria. The name of the cursor is MERGE.
-- If this is an embedded SELECT statement, no rows satisfy the
selection
--
Art Tostaine Jr
Rock Ridge Technology, Inc.
IBM i on Power Systems & LANSA services
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
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.