oracle – 必需声明标识符? PL / SQL错误
这是我写的措施: set serveroutput on; declare b empl.name1%type; r varchar; --can i change this to r empl.designation%type; ? begin r:=&designation; --getting input for the designation dbms_output.put_line('hello'); --random output to check for errors select name1 into b from empl where designation=r; --i want all the names from the table dbms_output.put_line('name'||b); --employee where designation is as entered dbms_output.put_line(' closed'); --by user,should i loop this statement? end; 当我输入指定为’a'(已在表中输入)时,我收到错误 我将措施改为: set serveroutput on; declare cursor cempl is select name1,designation from empl; b empl.name1%type; des empl.designation%type; r empl.designation%type; begin r:='meow'; dbms_output.put_line('hello'); open cempl; if cempl%ISOPEN then loop fetch cempl into b,des; if des=r then dbms_output.put_line('name'||b); end if; exit when cempl%notfound; end loop; close cempl; dbms_output.put_line(' closed'); end if; end; 每当我获得像r:=& r这样的输入并想象我输入’a’时就会说 >’Identifier not found’错误:& designation是一个SQL * Plus替代变量.当您为& names输入值时,SQL * Plus会行使您输入的内容替代& names.以是,假如你输入vaue a,那行 r:=&designation; 变 r:=a; 呈现错误是由于Oracle不知道任何名为a的对象.您尚未声明一个名为a的变量,而且没有进程或函数或其他任何名称为a的变量.假如你但愿最终功效是r:=’a’;,你必要写r:=’& designation’;> SELECT … INTO …仅在查询返回一行时有用.假如没有返回任何行,您将收到无数据发明错误,假如返回多行,则会呈现太多行错误.你应该只行使SELECT … INTO …假如你知道只有一个功效.假如也许有多个功效,则应行使游标.>’为什么SQL Developer不接管%rowtype’?应该这样做 – 你能想出一个给你带来贫困的例子吗?>在第二个示例中,您将一再最后一行,由于在光标无法找到更多行之后,您不会当即退出轮回.您应该在行前面移动直接位于获取行的下方. (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |