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

Home -> Community -> Usenet -> c.d.o.server -> Re: Convert code from SQL Server 2000 to SQL Plus for Oracle

Re: Convert code from SQL Server 2000 to SQL Plus for Oracle

From: Tim X <timx_at_spamto.devnul.com>
Date: 09 Apr 2003 20:11:48 +1000
Message-ID: <87ptnwq8t7.fsf@tiger.rapttech.com.au>


intikhab.bashir_at_corporate.ge.com (Intikhab Bashir) writes:

> Hi, how can I change the following so Oracle SQL can recognise.
> Thanks in advance:
>
>
> -------------------DATE-------------------------
> declare @year varchar(4)
> set @year = datepart(yy, getdate())
>
> declare @month varchar(2)
> set @month = datepart(month, getdate())
>
> if (@month) = '1'
> begin
> set @month = '12'
> set @year = @year -1
> end
> else
> set @month = @month - 1
>
> declare @monthName varchar(3)
> declare @day varchar(2)
>
> if @month = '1'
> begin
> set @day = '31'
> set @monthName = 'Jan'
> end
> else if @month = '3'
> begin
> set @day = '31'
> set @monthName = 'Mar'
> end
> else if @month = '4'
> begin
> set @day = '30'
> set @monthName = 'Apr'
> end
> else if @month = '5'
> begin
> set @day = '31'
> set @monthName = 'May'
> end
> else if @month = '6'
> begin
> set @day = '30'
> set @monthName = 'Jun'
> end
> else if @month = '7'
> begin
> set @day = '31'
> set @monthName = 'Jul'
> end
> else if @month = '8'
> begin
> set @day = '31'
> set @monthName = 'Aug'
> end
> else if @month = '9'
> begin
> set @day = '30'
> set @monthName = 'Sep'
> end
> else if @month = '10'
> begin
> set @day = '31'
> set @monthName = 'Oct'
> end
> else if @month = '11'
> begin
> set @day = '30'
> set @monthName = 'Nov'
> end
> else if @month = '12'
> begin
> set @day = '31'
> set @monthName = 'Dec'
> end
> else
> begin
> set @day = '28'
> set @monthName = 'Feb'
> end
>
>
> declare @date varchar(20)
> set @date = @monthName + ' ' + right(@year, 2)
>
> declare @from varchar(30)
> declare @to varchar(30)
>
> set @from = '01 ' + @date
> set @to = @day + ' ' + @date
>
> print @from
> print @to

Forget about conversion. Identify the algorithm being used and implement it using Oracle PL/SQL constructs. The problem is that Oracle PL/SQl is sufficiently different that there is no real 1-to-1 relationship and trying to just convert without proper analysis of what the code is trying to do will result in inefficient (if not buggy) code.

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
Received on Wed Apr 09 2003 - 05:11:48 CDT

Original text of this message

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