Greetings:
We are running Progression 7.6.300C on MSSQL Server 2000.
I am trying to do a bulk insert of Type 4 price codes into the OEPRCFIL_SQL table. I am trying to do this because Macola's COPY PRICE CODES application doesn't work with Type 4 Price codes. The goal is to create price codes for a new customer type.
We currently have a customer type of G which is a reseller customer that gets discounts based on quantity purchased. We have a a fairly large group of customers that we offer "End Column" pricing to due to the large amount of business that they do with us. So, I want to create a Customer Type of EC (End Column) that has ALL of the Type 4 Codes that the Type G customer has, with a few differences.
The EC Customer Type would only have a List Price, or minimum_qty_1, prc_or_disc_1 and the end column price which would live in minimum_qty_2, prc_or_disc_2. The minimum_qty_2, prc_or_disc_2 would have the last minimum_qty and prc_or_disc that is greater than zero for the Customer Type G customers. Therefore this is our end column price code. The only real difference between what exists and what is inserted is the left substring of the filler_0001 field which would change from 'G' to 'EC' and the end column attribute.
So, the plan is to run an insert statement in QA, then run an update statement in QA to create the End Column structure that I mentioned above.
My problem stems from the insert statement that I created in Query Analyzer. I was getting the following error:
Server: Msg 2601, Level 14, State 3, Line 3
Cannot insert duplicate key row in object 'OEPRCFIL_SQL' with unique index 'Ioeprcfil_sql0'.
The statement has been terminated.
Below is the insert statement that I used.
After that, I use the following update statement:
The update statement works beautifully. Can anyone tell me what is wrong with my insert statement? I DEFINITELY want to make sure that I don't violate primary key rules. I occurs to me that I need to have some sort of NOT EXISTS code in there but I don't know how to do that when you are inserting records into the same table you are basing the insert on.
Thanks in advance for your help.
Christopher J. Poulin
We are running Progression 7.6.300C on MSSQL Server 2000.
I am trying to do a bulk insert of Type 4 price codes into the OEPRCFIL_SQL table. I am trying to do this because Macola's COPY PRICE CODES application doesn't work with Type 4 Price codes. The goal is to create price codes for a new customer type.
We currently have a customer type of G which is a reseller customer that gets discounts based on quantity purchased. We have a a fairly large group of customers that we offer "End Column" pricing to due to the large amount of business that they do with us. So, I want to create a Customer Type of EC (End Column) that has ALL of the Type 4 Codes that the Type G customer has, with a few differences.
The EC Customer Type would only have a List Price, or minimum_qty_1, prc_or_disc_1 and the end column price which would live in minimum_qty_2, prc_or_disc_2. The minimum_qty_2, prc_or_disc_2 would have the last minimum_qty and prc_or_disc that is greater than zero for the Customer Type G customers. Therefore this is our end column price code. The only real difference between what exists and what is inserted is the left substring of the filler_0001 field which would change from 'G' to 'EC' and the end column attribute.
So, the plan is to run an insert statement in QA, then run an update statement in QA to create the End Column structure that I mentioned above.
My problem stems from the insert statement that I created in Query Analyzer. I was getting the following error:
Server: Msg 2601, Level 14, State 3, Line 3
Cannot insert duplicate key row in object 'OEPRCFIL_SQL' with unique index 'Ioeprcfil_sql0'.
The statement has been terminated.
Below is the insert statement that I used.
Code:
BEGIN TRAN
Insert into oeprcfil_sql
(cd_tp,
curr_cd,
filler_0001,
start_dt,
end_dt,
cd_prc_basis,
minimum_qty_1,
prc_or_disc_1,
minimum_qty_2,
prc_or_disc_2,
minimum_qty_3,
prc_or_disc_3,
minimum_qty_4,
prc_or_disc_4,
minimum_qty_5,
prc_or_disc_5,
minimum_qty_6,
prc_or_disc_6,
minimum_qty_7,
prc_or_disc_7,
minimum_qty_8,
prc_or_disc_8,
minimum_qty_9,
prc_or_disc_9,
minimum_qty_10,
prc_or_disc_10,
comm_pct,
filler_0004)
SELECT
cd_tp,
curr_cd,
'EC '+LTRIM(SUBSTRING(filler_0001, 6, 3)),
start_dt,
end_dt,
cd_prc_basis,
minimum_qty_1,
prc_or_disc_1,
minimum_qty_2,
prc_or_disc_2,
minimum_qty_3,
prc_or_disc_3,
minimum_qty_4,
prc_or_disc_4,
minimum_qty_5,
prc_or_disc_5,
minimum_qty_6,
prc_or_disc_6,
minimum_qty_7,
prc_or_disc_7,
minimum_qty_8,
prc_or_disc_8,
minimum_qty_9,
prc_or_disc_9,
minimum_qty_10,
prc_or_disc_10,
comm_pct,
filler_0004
FROM OEPRCFIL_SQL
WHERE cd_tp = '4' AND LTRIM(SUBSTRING(filler_0001, 1, 5)) = 'G'
After that, I use the following update statement:
Code:
BEGIN TRAN
UPDATE OEPRCFIL_SQL
SET prc_or_disc_2 =
CASE
WHEN prc_or_disc_10 >0 THEN prc_or_disc_10
WHEN prc_or_disc_9 >0 THEN prc_or_disc_9
WHEN prc_or_disc_8 >0 THEN prc_or_disc_8
WHEN prc_or_disc_7 >0 THEN prc_or_disc_7
WHEN prc_or_disc_6 >0 THEN prc_or_disc_6
WHEN prc_or_disc_5 >0 THEN prc_or_disc_5
WHEN prc_or_disc_4 >0 THEN prc_or_disc_4
WHEN prc_or_disc_3 >0 THEN prc_or_disc_3
WHEN prc_or_disc_2 >0 THEN prc_or_disc_2
ELSE 0
END,
prc_or_disc_3 = 0,
minimum_qty_3 = 0,
prc_or_disc_4 = 0,
minimum_qty_4 = 0,
prc_or_disc_5 = 0,
minimum_qty_5 = 0,
prc_or_disc_6 = 0,
minimum_qty_6 = 0,
prc_or_disc_7 = 0,
minimum_qty_7 = 0
FROM OEPRCFIL_SQL
WHERE LTRIM(SUBSTRING(filler_0001, 1, 5))='EC'
The update statement works beautifully. Can anyone tell me what is wrong with my insert statement? I DEFINITELY want to make sure that I don't violate primary key rules. I occurs to me that I need to have some sort of NOT EXISTS code in there but I don't know how to do that when you are inserting records into the same table you are basing the insert on.
Thanks in advance for your help.
Christopher J. Poulin