这是我的代码,不起作用
BEGIN
FOR r1
IN (SELECT *
FROM apex_application_temp_files f,
TABLE (
apex_data_parser.parse (
p_content => f.blob_content,
p_add_headers_row => 'Y',
p_file_name => f.filename)) p
WHERE f.name = :p24_upload AND line_number > 1)
LOOP
apex_collection.add_member (
p_collection_name => 'W',
p_c001 => NVL (REPLACE (r1.col001, '-', ''), NULL),
p_c002 => NVL (REPLACE (r1.col002, '-', ''), NULL),
p_c003 => NVL (REPLACE (r1.col003, '-', ''), NULL),
p_c004 => NVL (REPLACE (r1.col004, '-', ''), NULL),
p_c005 => NVL (REPLACE (r1.col005, '-', ''), NULL),
p_c006 => NVL (REPLACE (r1.col006, '-', ''), NULL),
p_c007 => NVL (REPLACE (r1.col007, '-', ''), NULL),
p_c008 => NVL (REPLACE (r1.col008, '-', ''), NULL),
p_c009 => NVL (REPLACE (r1.col009, '-', ''), NULL),
p_c010 => NVL (REPLACE (r1.col010, '-', ''), NULL),
p_c011 => NVL (REPLACE (r1.col011, '-', ''), NULL),
p_c012 => NVL (REPLACE (r1.col012, '-', ''), NULL),
p_c013 => NVL (REPLACE (r1.col013, '-', ''), NULL),
p_c014 => NVL (REPLACE (r1.col014, '-', ''), NULL),
p_c015 => NVL (REPLACE (r1.col015, '-', ''), NULL),
p_c016 => NVL (REPLACE (r1.col016, '-', ''), NULL),
p_c017 => NVL (REPLACE (r1.col017, '-', ''), NULL),
p_c018 => NVL (REPLACE (r1.col018, '-', ''), NULL),
p_c019 => NVL (REPLACE (r1.col019, '-', ''), NULL),
p_c020 => NVL (REPLACE (r1.col020, '-', ''), NULL),
p_c021 => NVL (REPLACE (r1.col021, '-', ''), NULL),
p_c022 => NVL (REPLACE (r1.col022, '-', ''), NULL),
p_c023 => NVL (REPLACE (r1.col023, '-', ''), NULL),
p_c024 => NVL (REPLACE (r1.col024, '-', ''), NULL),
p_c025 => NVL (REPLACE (r1.col025, '-', ''), NULL));
END LOOP;
END;
DECLARE
CURSOR c2
IS
(SELECT *
FROM apex_collections
WHERE collection_name = 'W');
BEGIN
FOR i IN c2
LOOP
BEGIN
INSERT INTO pos_cards_new (comp_id,
card_seq,
curncy_code,
curr_rate,
card_amt,
card_base_amt,
valid_from_date,
vald_to_date,
card_points,
card_balance,
card_isvalid,
iuser_id,
itime_stamp,
card_id,
customer_code,
employee_cridet_limit,
employee_cridet_curr_balance,
is_admin)
VALUES (
'IPOS',
I.C001,
(SELECT curncy_code
FROM pos_stp_currencies
WHERE curncy_desc_m = i.c003
AND comp_id = :p0_comp_id),
I.C004,
I.C005,
I.C006,
TO_CHAR (TO_DATE (I.C007, 'YYYYMMDD'),'dd/mm/yyyy'),
TO_CHAR (TO_DATE (I.C008, 'YYYYMMDD'),'dd/mm/yyyy'),
I.C009,
I.C010,
I.C014,
:app_user,
SYSDATE,
I.C002,
I.C013,
I.C015,
I.C016,
I.C017);
EXCEPTION
WHEN DUP_VAL_ON_INDEX
THEN
FOR i IN c2
LOOP
UPDATE pos_cards_new
SET card_amt = I.C005,
iuser_id = :app_user,
itime_stamp = SYSDATE,
valid_from_date = I.C007,
vald_to_date = I.C008
WHERE card_seq = I.C001;
END LOOP;
END;
END LOOP;
END;
第一次代码插入和第二次退出代码
给予我主键重复的错误
为什么!!
主键是card_seq
1条答案
按热度按时间guykilcj1#
使用
MERGE
语句: