在Oracle中创建游标时出错

时间:2015-11-18 21:53:57

标签: sql oracle

我有一个非常简单的脚本来尝试游标功能,但它报告了无效的CREATE COMMAND。任何人都知道原因可能是什么?谢谢!

create lot_1 cursor for select * from temp_minj1.lot

1 个答案:

答案 0 :(得分:1)

在Oracle中,SQL语法是:

DECLARE
  my_emp_id     NUMBER(6);      -- variable for employee_id
  my_job_id     VARCHAR2(10);   -- variable for job_id
  my_sal        NUMBER(8,2);    -- variable for salary
  CURSOR c1 IS SELECT employee_id, job_id, salary FROM employees
      WHERE salary > 2000; 
  my_dept   departments%ROWTYPE;  -- variable for departments row
  CURSOR c2 RETURN departments%ROWTYPE IS 
      SELECT * FROM departments WHERE department_id = 110;

see source