Subject | help with query |
---|---|
Author | jackmills75 |
Post date | 2005-02-23T17:22:22Z |
Hi
Table PTST has PK based on 3 columns UOP_NO, STATE_NO, TEST_NO, all
integer.
Rows get inserted e.g. with UOP_NO = 1, STATE_NO = 0, TEST_NO = 1
plus other column data but initially not with test_no = 0, I need to
add a new row setting TEST_NO = 0 with the existing UOP_NO & STATE_NO
This query runs once ok & then bombs out because of violation of
primary key (which I understand)
INSERT INTO PTST(UOP_NO, STATE_NO, TEST_NO, ABS_NO)
SELECT DISTINCT UOP_NO, STATE_NO, 0, -2
FROM PTST
Is there any way it can be modified so that once a row has TEST_NO =0
that there is no insert for that PK combination.
Hope that makes sense.
Thanks for any help
Jack
Table PTST has PK based on 3 columns UOP_NO, STATE_NO, TEST_NO, all
integer.
Rows get inserted e.g. with UOP_NO = 1, STATE_NO = 0, TEST_NO = 1
plus other column data but initially not with test_no = 0, I need to
add a new row setting TEST_NO = 0 with the existing UOP_NO & STATE_NO
This query runs once ok & then bombs out because of violation of
primary key (which I understand)
INSERT INTO PTST(UOP_NO, STATE_NO, TEST_NO, ABS_NO)
SELECT DISTINCT UOP_NO, STATE_NO, 0, -2
FROM PTST
Is there any way it can be modified so that once a row has TEST_NO =0
that there is no insert for that PK combination.
Hope that makes sense.
Thanks for any help
Jack