Oracle Apex:带有concat的条件值列表

时间:2013-06-10 09:36:28

标签: oracle plsql oracle-apex lov

我正在尝试在从页面项获取的条件下构建动态和条件LOV。我遇到了这个例子......

IF :P123_CHOICE = 'EMP' THEN
  RETURN
  'SELECT ename d, empno r
   FROM emp';
ELSE
  RETURN
  'SELECT dname d, deptno r
   FROM dept';
END IF;

但是我需要更复杂的东西:

IF :P123_CHOICE = 'EMP' THEN
  RETURN
  'SELECT ename||' : '||esurname d, empno r
   FROM emp
   WHERE (admin ='N' or ADMIN = 'Y')
   ';
ELSE
  RETURN

  'SELECT ename||' : '||esurname d, empno r
   FROM emp
   WHERE admin ='N'
   ';
END IF;

结果我得到错误:

*ORA-06550: line 3, column 21: PL/SQL: ORA-01756: quoted string not properly terminated ORA-01756: quoted string not properly terminated ORA-06550: line 1, column 13: PL/SQL: SQL Statement ignored ORA-06550: line 5, column 4: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ; ORA-01756: quoted string not properly terminated*

这显然是我无法解决的格式化问题。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

为了绕过特殊字符:

IF :P123_CHOICE = 'EMP' THEN
RETURN
      q'[select ... ]';
ELSE
RETURN
      q'[ select ...]';
END IF;

Oracle® Database PL/SQL Language Reference 11g Release 1 (11.1)