If I understand your question correctly, you're trying to return data from PL/SQL using the query mentioned. While a procedure in SQL Server can return data as a result set, an Oracle procedure cannot do this the same way.
Consider the following example
DECLARE
n number;
numvalue number;
datevalue date;
BEGIN
n := 10;
SELECT SYSDATE, n
FROM dual;
END;
/
This would case an
ORA-06550
error since an
INTO
clause is expected. In other words, you need to return the data to variables.
Note that I didn't use colon before the variable names. Colon is typically used in client side programs to indicate a bind variable, but not inside a PL/SQL block.
Now, if you change the block to the following
DECLARE
n number;
numvalue number;
datevalue date;
BEGIN
n := 10;
SELECT SYSDATE, n
INTO datevalue, numvalue
FROM dual;
RAISE_APPLICATION_ERROR(-20001, 'Date: ' || TO_CHAR(datevalue) || ', numvalue: ' || TO_CHAR(numvalue));
END;
/
When the block is executed the query works fine and you can see the result via the custom exception. The result should be
ORA-20001: Date: 10-JAN-20, numvalue: 10
So now the data is known inside the block. In order to return this data to the calling program you have several options. For example you can use a REF_CURSOR, define table type use a pipeline function and so on.
For few examples to return data, have a look at
Examples for Creating Oracle Functions[
^]