Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL & sysdate

Re: PL/SQL & sysdate

From: Hakan Eren <heren_at_home.com>
Date: 2000/06/23
Message-ID: <3953787F.A7E5E1BE@home.com>#1/1

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 - Production                           
5 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> /

Statement processed.
This year is: 2000
SQLWKS> connect scott_at_orac8
Connected.
SQLWKS> set serveroutput on
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 - Production                           
5 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> /

Statement processed.
This year is: 2000

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US