Skip to content
Advertisement

How can I translate a query from SQL Server to Oracle?

I’m trying to migrate a simple stored procedure from SQL Server to Oracle.

I have already tried a few online converters but with no success, such as the Scratch editor. Can anyone help?

CREATE PROCEDURE [dbo].[Test] @DOCID INT 
AS 
    DECLARE @TXT VARCHAR(500); 

    SET @TXT= Concat ('Test ', (SELECT CONVERT(VARCHAR(10), d5, 2) 
                                FROM   data6 
                                WHERE  id = @DOCID), ',', 'and ', 
              Char(10) + Char(13), (SELECT d2 
                                   FROM data6 
                                   WHERE id = @DOCID))

Advertisement

Answer

I am not sure I completely understand that syntax, but it seems this is a simple SELECT statement:

create or replace procedure test(doc_id number)
as
  l_text varchar(500);
begin
  select 'Test'||to_char(d5,'yy.mm.dd')||chr(10)||chr(13)||d2
    into l_text
  from data6
  where id = doc_id;
end;

Not sure what the convert() function does, I think the 2 means that you are trying to format a date.

Online example

6 People found this is helpful
Advertisement