我怎么能写这个代码在oracle中工作?

时间:2015-07-16 06:26:06

标签: sql-server oracle

如何编写此代码(Sql Server)以在Oracle PL / SQl中工作?

  DECLARE @ID INTEGER

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

  FROM EmployeeTable

2 个答案:

答案 0 :(得分:2)

以下是oracle

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

答案 1 :(得分:1)

试试这个PL / SQL块:

DECLARE ID INTEGER;

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