Oracle PL/SQL select into variables

前端 未结 2 1644
甜味超标
甜味超标 2020-12-19 22:32

I am trying to run the following query in SQL Developer, but I am receiving an error. I am trying to declare two local variables (var_num1 and payDate) and then set the var

2条回答
  •  时光说笑
    2020-12-19 22:57

    If you want to get a resultset back in SQL Developer with this code block you will need to open a ref cursor for the query e.g.

    DECLARE
      refCur REF CURSOR;
      refc refCur;
      var_num1 number; 
      payDate date;
      v_result Paycode%ROWTYPE;
    BEGIN 
      var_num1 := 100; 
      payDate := '10/1/2013';
    
    OPEN refc FOR
        SELECT * 
        FROM Paycode
        WHERE PaycodeID = var_num1 and PaycodeDate = payDate;
    
    END; 
    

提交回复
热议问题