DB2 support a WITH on an insert
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzbackup.htm
<snip>
WITH common-table-expression
Specifies a common table expression. For an explanation of common table expression, see common-table-expression.
</snip>
I just need to figure out how to do it.
Why WITH?
Because my select without an insert gives me exactly what I want.
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of smith5646midrange@xxxxxxxxx
Sent: Friday, February 22, 2019 2:35 PM
To: 'Midrange Systems Technical Discussion' <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Using a "with" on an insert
I also do not think DB2 accepts the "with" on an insert. Why are you trying to use a with?
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of dlclark@xxxxxxxxxxxxxxxx
Sent: Friday, February 22, 2019 2:18 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Using a "with" on an insert
"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 02/22/2019
02:00:27 PM:
How do use a "WITH" on an insert?
It's dying right here:
insert into mytable values (
With T1 as (...
SQL State: 42601 Vendor Code: -104 Message: [SQL0104] Token WITH was
not valid. Valid tokens: (. Cause . . . . . : A syntax error was
detected at token WITH. Token WITH is not a valid token. A partial
list of valid tokens is (. This list assumes that the statement is
correct up to the token.
Normally, the syntax is as follows -- no VALUES phrase. Are you trying to create a subselect in the VALUES phrase? I'm not sure that subselects support common table expressions of their own.
INSERT ...
(column names...)
WITH ...
SELECT ...
Sincerely,
Dave Clark
--
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300
Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio 45439 USA
(937) 294-5331
****************************************************************************
*****************
This email message and any attachments is for use only by the named
addressee(s) and may contain confidential, privileged and/or proprietary information. If you have received this message in error, please immediately notify the sender and delete and destroy the message and all copies. All unauthorized direct or indirect use or disclosure of this message is strictly prohibited. No right to confidentiality or privilege is waived or lost by any error in transmission.
****************************************************************************
*****************
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
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:
https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
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:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.