我想用3個字符串來表示一組姓氏,名字和中間名。爲什麼BULK COLLECT在Oracle Package PROC中給出了一個錯誤的綁定變量編譯錯誤?
傳入的參數,最終會看起來像這樣:
lastNames IN VARCHAR2 := NULL
'Smith/Brown/Green'
firstNames IN VARCHAR2 := NULL,
'Joseph/Dan/Sam'
miNames IN VARCHAR2 := NULL,
'c.//J.'
這樣做的目的是建立這樣的動態SQL過濾器:
v_namesFilter VARCHAR(32767 BYTE);
v_namesFilter := ' AND (last_name = ''Smith'' AND middle_name = ''C'' AND first_name = ''Joseph'') OR (last_name = ''Brown'' AND first_name = ''Dan'') OR (last_name = ''Green'' AND middle_name = ''J.'' AND first_name = ''Sam'')
到目前爲止,我有來電PARAM像這樣的:再經過
lastNames IN VARCHAR2 := NULL,
IS(
我:
v_last_names_tab LAST_NAMES_TAB;
LAST_NAMES_TAB的定義是這樣的:
create or replace TYPE "LAST_NAMES_TAB" AS TABLE OF LAST_NAMES;
LAST_NAMES的定義是這樣的:
create or replaceTYPE "LAST_NAMES" AS OBJECT(
lastName VARCHAR2(32767)
);
後,我首先,我有:
-- split last names into table
SELECT LAST_NAMES(lastName)
BULK COLLECT INTO :v_last_names_tab
FROM (
SELECT trim(regexp_substr(lastNames, '[^/]+', 1, LEVEL))AS lastName
FROM DUAL
CONNECT BY instr(lastNames, '/', 1, LEVEL - 1) > 0
);
我認爲這將填補了一個名爲TYPE LAST_NAMES_TAB的v_last_names_tab表是這樣的:
lastName
--------
Smith
Brown
Green
,但我得到「壞綁定變量‘:v_last_names_tab’錯誤消息時我嘗試編譯。
我該如何格式化我的傳入數據,這樣我才能瀏覽它。
您不需要使用冒號(「:」)來指示PL/SQL上下文中的綁定變量。 – mustaccio