CREATE OR REPLACE
PROCEDURE "SCD_DIM_MATERIAL_INITIAL" AS
TYPE SCD_RECORD IS RECORD(
ORD NUMBER(2),
PRIMARYID R5AUDVALUES.AVA_PRIMARYID%TYPE,
AVA_FROM R5AUDVALUES.AVA_FROM%TYPE,
AVA_TO R5AUDVALUES.AVA_TO%TYPE,
AVA_CHANGED R5AUDVALUES.AVA_CHANGED%TYPE
);
SCD_RECORD_1 SCD_RECORD;
TYPE CUR IS REF CURSOR;
SCD_DIM_MATERIAL CUR;
sqlString VARCHAR(256);
MATERIAL_CODE R5AUDVALUES.AVA_PRIMARYID%TYPE;
BEGIN
-- routine body goes here, e.g.
-- DBMS_OUTPUT.PUT_LINE('Navicat for Oracle');
FOR MATERIAL_CODE IN (SELECT DISTINCT AUD.AVA_PRIMARYID FROM R5AUDVALUES AUD)
LOOP
sqlString:='SELECT
RANK() OVER (ORDER BY AVA_CHANGED) ORD,
AVA_PRIMARYID,
AVA_FROM,
AVA_TO,AVA_CHANGED
FROM R5AUDVALUES
WHERE AVA_PRIMARYID='||MATERIAL_CODE;
OPEN SCD_DIM_MATERIAL FOR sqlString;
FETCH SCD_DIM_MATERIAL INTO SCD_RECORD_1;
LOOP
EXIT WHEN SCD_DIM_MATERIAL%NOTFOUND;
END LOOP;
END LOOP;
END;
我想首先用一个FOR IN LOOP取出一张表的字段PRIMARYID,然后根据PRIMARYID动态生成游标,再在这个游标中对每条数据进行分别处理。
报错:wrong number or types of arguements in call to ‘||’。
字面理解应该是处理字符串链接符的时候参数出错了,我看这个链接字符串应该没什么问题啊?
请各位帮忙看看? ------解决方案--------------------
sqlString:='SELECT
RANK() OVER (ORDER BY AVA_CHANGED) ORD,
AVA_PRIMARYID,
AVA_FROM,
AVA_TO,AVA_CHANGED
FROM R5AUDVALUES
WHERE AVA_PRIMARYID=' ------解决方案-------------------- MATERIAL_CODE;
改为: