Luhyun
Luhyun

Reputation: 1

How I can write this code to work in oracle?

How I can write this code ( Sql Server) to work in Oracle PL/SQl ?

  DECLARE @ID INTEGER

  SELECT @ID = ISNULL(MAX(EmployeeID),0) + 1

  FROM EmployeeTable

Upvotes: 1

Views: 58

Answers (2)

Tharunkumar Reddy
Tharunkumar Reddy

Reputation: 2813

Below is the equivalent code for oracle

declare
    id number;
    begin
    select nvl(max(employeeid),0)+1 into id from employeetable;
    dbms_output.put_line(id);
    end;

Upvotes: 2

Stefan Yordanov
Stefan Yordanov

Reputation: 666

Try this PL/SQL block:

DECLARE ID INTEGER;

BEGIN
SELECT
    NVL(MAX(EmployeeID),0) + 1 INTO ID
FROM
    EmployeeTable
END;
/

Upvotes: 1

Related Questions