Pl-sql代码显示错误

时间:2016-10-01 17:07:45

标签: sql oracle plsql

我是pl-sql的新手。以下代码生成错误

declare
c number;
a varchar2(20);
b varchar2(20);
begin
a:='appy';
b:='1234';
select count(*) in c from userdetails where userid=a and password=b;
dbms_output.put_line('=--=-='||c);
end;
/

正在生成错误消息

select count(*) in c from userdetails where userid=a and password=p;
                *
ERROR at line 8:
ORA-06550: line 8, column 17:
PL/SQL: ORA-00923: FROM keyword not found where expected
ORA-06550: line 8, column 1:
PL/SQL: SQL Statement ignored

我的表是userdetails,有2列userid和密码都是varchar2类型。

1 个答案:

答案 0 :(得分:2)

如果要将查询结果选择为c,请尝试替换" in"进入"进入"你还应该指定你选择的表格:

declare
    c number;
    a varchar2(20);
    b varchar2(20);
begin
    a:='appy';
    b:='1234';
    select count(*) into c from userdetails where userid=a and password=b;
    dbms_output.put_line('=--=-='||c);
end;

有关详细信息,请阅读docs