Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL & sysdate
hi,
I don't see any problem with you code. anyway i tested in oracle 7 and 8:
SQLWKS> set serveroutput on
Server Output ON SQLWKS> select * from v$version; BANNER ---------------------------------------------------------------- Oracle7 Server Release 7.3.4.5.0 - Production PL/SQL Release 2.3.4.5.0 - Production CORE Version 3.5.4.0.0 - Production TNS for 32-bit Windows: Version 2.3.4.0.0 - Production NLSRTL Version 3.2.4.0.1 - Production5 rows selected.
SQLWKS> declare 2> thisyear number; 3> begin 4> select to_number(to_char(sysdate, 'YYYY')) 5> into thisyear from dual; 6> dbms_output.put_line('This year is: ' || thisyear); 7> end; 8> /
Server Output ON SQLWKS> select * from v$version; BANNER ---------------------------------------------------------------- Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production PL/SQL Release 8.1.6.0.0 - Production CORE 8.1.6.0.0 Production TNS for 32-bit Windows: Version 8.1.6.0.0 - Production NLSRTL Version 3.4.1.0.0 - Production5 rows selected.
SQLWKS> declare 2> thisyear number; 3> begin 4> select to_number(to_char(sysdate, 'YYYY')) 5> into thisyear from dual; 6> dbms_output.put_line('This year is: ' || thisyear); 7> end; 8> /
regards
Hakan
blank214_at_my-deja.com wrote:
>
> I want to get the current year from the database & convert it to a
> number. The PL/SQL block compiles, but hangs when I try to execute it.
> The following is the problem statement:
>
> select to_number(to_char(sysdate, 'YYYY'))
> into thisyear from dual;
>
> What am I doing wrong?
>
> Thanks in advance - Jennifer
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Fri Jun 23 2000 - 00:00:00 CDT
![]() |
![]() |