title: Convert SQL Server stored procedure to Oracle stored procedure
body: <p>Hi I am very new to Oracle, please help me to convert the below SQL Server stored procedure to an Oracle stored procedure.</p>
  
  <p>Below is shown the SQL Server stored procedure that I am trying to convert to Oracle, but due to little time I am not able to find a solution, please help me.</p>
  
  <pre><code>Create PROCEDURE dbo.myprocedure
      @name          VarChar(50),
      @columnid  VarChar(50),
      @max   Int OUTPUT
  
  AS
   DECLARE @period int,
           @myStatement  varChar(255)
   SET @period = 99999
   SET @max   = 0
  
   Create Table #newtable
   (
     valu INT
   )
  
   SET @myStatement  = 'Insert INTO #newtable(valu) SELECT max( ' + @columnid + ') FROM ' + @name + ' WHERE ' + 
  
  @columnid+ ' &lt;= ' + Convert(varChar(5), @period)
   EXEC ( @myStatement )
   SELECT @max = valu FROM  #newtable
  
   IF (@max = @period)
      SET @max =-1
   ELSE
      SET @max= @max+ 1   
   DROP Table #newtable
  
  GO
  </code></pre>
  
  <p>this  is how i changed into oracle stored procedure</p>
  
  <pre><code>Create Table newtable(   valu INT );
  CREATE OR REPLACE
  PROCEDURE PROCEDURE1
  ( name IN VARCHAR2
  , columnid  IN VARCHAR2
  , maxid IN OUT VARCHAR2
  )
  as
           period number;
           mystatement  varChar(255);   
     BEGIN
    period:= 99999; 
  maxid:= 0;
  
    mystatement:= 'Insert INTO newtable(valu) SELECT max(columnid) FROM name WHERE columnid  &lt;=  Convert(varChar(5), period)';  
  
   SELECT maxid = valu FROM  newtable;
  
     EXECUTE immediate mystatement;
  
   IF (maxid= period)
      return maxid:=-1;
   ELSE
  
      return maxid:=  maxid + 1;  
  
   DROP Table newtable;
  
  END PROCEDURE1;
  </code></pre>