Поиск по этому блогу

четверг, 18 июля 2013 г.

Interesting behaviour of SYSDATE in oracle

Everybody knows that SYSDATE if the funtion which shows current date in Oracle

select sysdate from dual

But let's try to use SYSDATE in PL/SQL


declare
sysdate integer;
begin
  sysdate:=1;
  dbms_output.put_line(sysdate);
  end;

Wery confusing. Is not it. How SYSDATE can be integer and how date can equals 1.
But in fact this block returs 1 and number succesfully initialize to SYSDATE variable.Yes in this context SYSDATE is just a varible name. This is becuse PL/SQL enjine does not have it's own SYSDATE and it have to ask SQL for the result. In this pease of code we are not using SQL just PL so SYSDATE is an integer and block returns 1.

Комментариев нет:

Отправить комментарий