Query within a function [message #35999] |
Mon, 29 October 2001 19:19 |
Rajarshi Dasgupta
Messages: 52 Registered: October 2001
|
Member |
|
|
In SQL a query within a function works but not in PL/SQL.
Example:
********
SQL:
SELECT to_char((SELECT sysdate FROM dual), 'DD/MM/YYYY') FROM dual;
This SQL works properly.
PL/SQL:
DECLARE
var VARCHAR2(20);
BEGIN
SELECT to_char((SELECT SYSDATE FROM dual))
INTO var
FROM dual;
END;
/
This PL/SQL doesnot work. It gives an error.
WHY? And how can I overcome it?
----------------------------------------------------------------------
|
|
|
Re: Query within a function [message #36006 is a reply to message #35999] |
Mon, 29 October 2001 21:56 |
Satish Shrikhande
Messages: 167 Registered: October 2001
|
Senior Member |
|
|
Try this
DECLARE
var VARCHAR2(20);
BEGIN
SELECT to_char(d.d, 'DD/MM/YYYY') into var
FROM (SELECT sysdate d FROM dual) d;
dbms_output.put_line(var);
END;
----------------------------------------------------------------------
|
|
|