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
You cannot use SELECT without INTO clause in PL/SQL. The output of the SELECT must be stored somewhere. Eg. table or variable or perhaps a record. See example below how to store result of the SELECT statement into record.
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;
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;