每当我尝试执行我的存储过程时,我得到错误我怀疑我的第三个参数FULL_FILE_NAME(K_XVL_10704_20151703_003.000)因为我包含点(。)。我怎么能传递第三个参数。如果我知道我可以告诉我在某个地方做错了。
CREATE OR REPLACE PROCEDURE DE_DUP_PROC2 (Dy_File_Name IN VARCHAR2,
SUPPLIER_CD IN VARCHAR2,
FULL_FILE_NAME IN VARCHAR2)
Declare
ORGNIZATION_ID VARCHAR2(20);
v_sql4 VARCHAR2(200);
DE_DUP_COUNT NUMBER(38);
BEGIN
SELECT ORG_ID INTO ORGNIZATION_ID FROM ps_org WHERE ORG_SHORT_NM = SUPPLIER_CD;
v_sql3 :=
' SELECT count(*) FROM (SELECT stg.*, row_number() over (partition BY key_clmns_hash ORDER BY 1) AS RN FROM '
|| Dy_File_Name || ' stg ) s JOIN ps_pharmacy p ON s.extrnl_pharmacy_id = p.extrnl_pharmacy_id LEFT JOIN ps_rx_hist H ON h.key_clmns_hash = s.key_clmnS_hash
AND h.rx_dspnsd_dt = s.rx_dspnsd_dt AND s.supplier_pharmacy_cd = h.SUPPLIER_PHARMACY_CD WHERE S.RN > 1 OR s.detl_clmns_hash = h.detl_clmns_hash ' ;
EXECUTE IMMEDIATE v_sql3 INTO DE_DUP_COUNT;
IF DE_DUP_COUNT > 0
THEN
v_sql4 :=
' declare
SRC_ID NUMBER(38) := SRC_FILE_ID_SEQ.nextval;
begin
insert into PS_FILE ( SRC_FILE_ID,FILE_NM,FILE_PROC_DT ,ORG_ID) values(SRC_ID,' || FULL_FILE_NAME || ', SYSDATE , ' || ORGNIZATION_ID || ' );
commit;
FOR i in ( '
|| ' SELECT S.TRANS_GUID AS OLD_TRANS_GUID,S.DETL_CLMNS_HASH AS DETL_CLMNS_HASH1 ,S.KEY_CLMNS_HASH AS KEY_CLMNS_HASH1,S.RX_DSPNSD_DT AS R_DSPNSD_DT,
S.SUPPLIER_PHARMACY_CD AS SUPPLIER_PHARMACY_CD1 FROM (SELECT stg.*, row_number() over (partition BY key_clmns_hash ORDER BY 1) AS RN FROM
'
|| Dy_File_Name || ' stg ) s JOIN ps_pharmacy p ON s.extrnl_pharmacy_id = p.extrnl_pharmacy_id LEFT JOIN ps_rx_hist H
ON h.key_clmns_hash = s.key_clmnS_hash
AND h.rx_dspnsd_dt = s.rx_dspnsd_dt
AND s.supplier_pharmacy_cd = h.SUPPLIER_PHARMACY_CD
WHERE S.RN > 1
OR s.detl_clmns_hash = h.detl_clmns_hash ' || ')' || ' LOOP ' || ' ' || '
insert into PS_RX_DUPES2(TRANS_GUID,DETL_CLMNS_HASH,KEY_CLMNS_HASH,RX_DSPNSD_DT,SUPPLIER_PHARMACY_CD,SRC_FILE_ID)
values(i.OLD_TRANS_GUID,i.DETL_CLMNS_HASH1,i.KEY_CLMNS_HASH1,i.R_DSPNSD_DT,i.SUPPLIER_PHARMACY_CD1,SRC_ID);
commit; ' || ' END LOOP;' || ' END;';
dbms_output.put_line(v_sql4);
EXECUTE IMMEDIATE v_sql4;
END IF;
END DE_DUP_PROC2;
当我执行时,我得到以下错误:
declare
OUTPUT_STATUS number(2);
begin
DE_DUP_PROC2('10655_20150318_04119297','MCL','K_XVL_10704_20151703_003.000');
end;
Error at line 1
ORA-06550: line 2, column 118:
PL/SQL: ORA-00917: missing comma
ORA-06550: line 2, column 16:
PL/SQL: SQL Statement ignored
ORA-06512: at "PS_ADMIN.DE_DUP_PROC2", line 4
ORA-06512: at line 2
答案 0 :(得分:1)
首先关于程序无法编译 - 应该有IS / AS而不是DECLARE而你错过了v_sql3变量的声明。
其次,如果我假设FULL_FILE_NAME和ORGANIZATION_ID是值而不是列名,则必须用单引号括起来,如
' ...值(SRC_ID,''' || FULL_FILE_NAME ||''',SYSDATE,' '' || ORGNIZATION_ID ||''')'。
v_sql4的长度也太小了。
之后很可能更多。