我想根据从 gui 中选择的标准动态构建查询。这是我的甲骨文包,
CREATE OR REPLACE PACKAGE TestPkg
AS
g_lastnamelist VARCHAR2(50);
FUNCTION getLastName return VARCHAR2;
FUNCTION buildQuery(p_lastnamelist VARCHAR2);
END;
CREATE OR REPLACE PACKAGE BODY TestPkg
AS
FUNCTION getLastName return VARCHAR2
IS
BEGIN
RETURN replace(g_lastnamelist, '''', '');
END;
FUNCTION buildQuery(p_lastnamelist VARCHAR2);
IS
m_query varchar2(1000);
BEGIN
g_lastnamelist := p_lastnamelist;
m_query := 'SELECT * FROM emp WHERE last_name IN(TestPkg.getLastName)';
END;
END;
在这里,如果我使用'SELECT * FROM emp WHERE last_name IN('||p_lastnamelist||')';
它,它会返回正确的记录,但如果我'SELECT * FROM emp WHERE last_name IN(TestPkg.getLastName)';
这样使用,那么它会失败。什么原因。
提前致谢。