I keep getting an error next to the return VARCHAR(4)

戏子无情 提交于 2019-12-02 16:50:06

问题


ERROR IS BETWEEN THE VARCHAR2 AND THE (4) seems to be a syntax error.

create or replace

    FUNCTION Employee_exists
        (p_employee_id IN NUMBER)
    RETURN VARCHAR2(4);

    AS
    BEGIN
        SELECT employee_id
        FROM employees
        WHERE employee_id = p_employee_id;
        RETURN 'true';
    END Employee_exists;

回答1:


There are actually two errors:

  1. You can't specify the length of the return type in a function or procedure specification
  2. ; is a statement terminator, as such it has no place between the return type and AS

Your first line should be:

FUNCTION employee_exists
        (p_employee_id IN NUMBER)
    RETURN VARCHAR2 AS



回答2:


    create or replace function test_fun(id in number)
    return long
    as
    disp_price long;
    Begin
    select price into disp_price from orders
    where id=2;
    return disp_price;
    end test_fun;

-----------------------------------------------------------
OUTPUT
-----------------------------------------------------------
declare
m_price long;
begin
m_price:=test_fun(1);
end;


来源:https://stackoverflow.com/questions/19119289/i-keep-getting-an-error-next-to-the-return-varchar4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!