Connecting Tech Pros Worldwide Forums | Help | Site Map

DB2 SQL insert question

kaming
Guest
 
Posts: n/a
#1: Jul 12 '06
Dear all,

I know that we could insert data from a table to another table by

insert into A(F1,F2) select F1,F2 from B;

However, it seems that DB2 doesn't have insert update for this kind of
statement (i.e. The insertion failed if primary key already exist in A,
while we could do this in import statement)

Is that I missed something from the manuel? The work around I think of
is to delete the records beforehand, could anyone tell me whether this
could be done in the same statement?

Thanks in advance!

Henry


mike
Guest
 
Posts: n/a
#2: Jul 12 '06

re: DB2 SQL insert question


Consider " Insert into...select ... from... where not exists ...."
or the MERGE statement might help you, if available on your platform
and version.

Gert van der Kooij
Guest
 
Posts: n/a
#3: Jul 12 '06

re: DB2 SQL insert question


In article <1152689383.385937.38260@m73g2000cwd.googlegroups. com>,
busilogicoo@gmail.com says...
Quote:
Dear all,
>
I know that we could insert data from a table to another table by
>
insert into A(F1,F2) select F1,F2 from B;
>
However, it seems that DB2 doesn't have insert update for this kind of
statement (i.e. The insertion failed if primary key already exist in A,
while we could do this in import statement)
>
Is that I missed something from the manuel? The work around I think of
is to delete the records beforehand, could anyone tell me whether this
could be done in the same statement?
>
Thanks in advance!
>
Henry
>
>
Check the MERGE statement at http://tinyurl.com/o2hxe
Closed Thread