1

我正在尝试根据从页面项目中获取的条件构建动态和有条件的 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*

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

4

1 回答 1

3

为了绕过特殊字符:

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

Oracle® 数据库 PL/SQL 语言参考 11g 第 1 版 (11.1)

于 2013-06-10T10:00:59.510 回答