SELECT Without FROM Clause in Oracle Database 23ai/26ai
From Oracle 23ai/26ai onward we can use a SELECT without a FROM clause in some circumstances.
oracle 23configurationintermediate
by OracleDba
15 views
From Oracle 23ai/26ai onward we can use a SELECT without a FROM clause in some circumstances.
12345678910111213141516
select sysdate;
SYSDATE
---------
04-APR-23
SQL>
select sysdate from dual;
SYSDATE
---------
04-APR-23
SQL>12345678910111213141516
set serveroutput on
declare
v_date date;
begin
select sysdate
into v_date;
dbms_output.put_line(v_date);
end;
/
04-APR-23
PL/SQL procedure successfully completed.
SQL>12345678910111213141516171819202122232425262728293031323334353637
create or replace procedure get_date as
begin
select sysdate;
end;
/
Warning: Procedure created with compilation errors.
SQL>show errors
Errors for PROCEDURE GET_DATE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
3/3 PLS-00428: an INTO clause is expected in this SELECT statement
SQL>
create or replace procedure get_date as
l_cursor sys_refcursor;
begin
open l_cursor for
select sysdate;
dbms_sql.return_result(l_cursor);
end;
/
exec get_date;
PL/SQL procedure successfully completed.
ResultSet #1
SYSDATE
---------
04-APR-23
SQL>123456789101112131415161718192021222324252627
conn sys/SysPassword1@//localhost:1521/freepdb1 as sysdba
alter system flush shared_pool;
conn testuser1/testuser1@//localhost:1521/freepdb1
set linesize 100
column value format a65
select value
from v$diag_info
where name = 'Default Trace File';
VALUE
-----------------------------------------------------------------
/opt/oracle/diag/rdbms/free/FREE/trace/FREE_ora_17498.trc
SQL>
alter session set events '10053 trace name context forever';
select sysdate;
alter session set events '10053 trace name context off';
Final query after transformations:******* UNPARSED QUERY IS *******
SELECT SYSDATE@! "SYSDATE" FROM "SYS"."DUAL" "DUAL"Please to add comments
No comments yet. Be the first to comment!