-1

但是,尝试使用此处提供的此代码时,它会在尝试运行时返回以下错误:

    PLS-00103:在预期以下情况之一时遇到符号“IS”:

    常量异常表 long double ref char 时间时间戳间隔
    日期二进制国家字符 nchar

    1. 声明
    2.emp员工%ROWTYPE;
    3. tbl_emp 是 emp 表;
    4. v_user_type 员工.user_type%TYPE;
    5. 开始

代码是:

DECLARE
  emp employee%ROWTYPE; 
  tbl_emp IS TABLE OF emp;
  v_user_type employee.user_type%TYPE;
BEGIN
  SELECT user_type
  INTO v_user_type
  FROM Employee 
  WHERE upper(username) = v('APP_USER');
  IF v_user_type = 1 
  THEN
    SELECT * BULK COLLECT INTO tbl_emp
    FROM employee;
  ELSE
    SELECT * BULK COLLECT INTO tbl_emp
    FROM employee;
    WHERE upper(username) = v('APP_USER');
  END IF;
END;
/
4

1 回答 1

1

您需要先声明类型,然后声明该类型的变量。

例如

declare 
  type tbl_emp_type IS TABLE OF employee%ROWTYPE; 
  tbl_emp tbl_emp_type; 
begin

  select * 
  bulk collect into tbl_emp
  from employee;

end;

SQL小提琴

于 2013-04-24T10:36:47.577 回答