我创建了一个函数,想实现向userinfo表里插入数据的功能,userinfo表里一共有三个字段:username、password。代码如下:create or replace function fun_register(v_name varchar2, v_password varchar2);
begin
    insert into userinfo values (v_name,v_password);
end;
/却报出了这样的错误:
LINE/COL ERROR
-------- -----------------------------------------------------------------------------------------
1/59     PLS-00103: Encountered the symbol ";" when expecting one of the following:       return这是怎么回事呢?

解决方案 »

  1.   

    函数必须有返回值,即return 部分,结构也不对,分号改成as.
    这个函数没必要返回什么,可以改成过程
    create or replace function .. (...) return TYPE as
    ..
    begin
    ..
    end;
      

  2.   

    create or replace procedure pro_register(v_name varchar2, v_password varchar2)as
    begin
        insert into userinfo values (v_name,v_password);
    end;
      

  3.   

    create or replace procedure pro_register(v_name varchar2, v_password varchar2)as
    begin
        insert into userinfo values (v_name,v_password);
    end;
      

  4.   

    create or replace function fun_register(v_name varchar2, v_password varchar2);
    begin
        insert into userinfo(username,password) values (v_name,v_password);
    --该表一共有三个字段,但你确只插入了2个字段的值,所以应该显示指出将要被插入的值所对应字段.即:在表名后带上将要插入的字段名称
    end;
    /