Oracle PL / SQL选择变量

前端之家收集整理的这篇文章主要介绍了Oracle PL / SQL选择变量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在sql Developer中运行以下查询,但我收到一个错误.我试图声明两个局部变量(var_num1和payDate),然后设置变量.有谁知道我做错了什么?我知道Oracle sqlsql Server有点不同.
DECLARE
  var_num1 number; 
  payDate date;
 BEGIN 
  var_num1 := 100; 
  payDate := '10/1/2013'
  BEGIN 
    SELECT * FROM Paycode WHERE PaycodeID = var_num1 and PaycodeDate = payDate;
  End;
END;
Error report:
ORA-06550: line 6,column 2:
PLS-00428: an INTO clause is expected in this SELECT statement
06550. 00000 -  "line %s,column %s:\n%s"
*Cause:    Usually a PL/sql compilation error.
*Action:
在PL / sql中不能使用SELECT而不使用INTO子句. SELECT的输出必须存储在某处.例如.表或变量或者记录.请参阅下面的示例如何将SELECT语句的结果存储到记录中.
DECLARE
  var_num1 number; 
  payDate date;
  v_result Paycode%ROWTYPE;
BEGIN 
  var_num1 := 100; 
  payDate := '10/1/2013';

    SELECT * INTO v_result
    FROM Paycode
    WHERE PaycodeID = var_num1 and PaycodeDate = payDate;

END;

猜你在找的Oracle相关文章