【发布时间】:2014-02-10 06:39:21
【问题描述】:
> set serveroutput on
> set autoprint on;
> declare
> v_first_name employees.first_name%type;
> v_street_address locations.street_address%type;
> v_city locations.city%type;
> v_postal_code locations.postal_code%type;
> begin
> select employee_id first_name,street_address,city,postal_code into:b_employee_id,v_first_name,v_street_address,v_city,v_postal_code
>
> from employees natural join locations
> where employee_id=156; // how to get employee_id stored in b_employee_ud
> dbms_output.put_line('the employee'||v_first_name ||' is located at:'||v_street_address|| v_city ||v_postal_code );
> end;
> /
出现错误 错误报告: ORA-06550:第 7 行,第 134 列: PL/SQL: ORA-00913: 值太多 ORA-06550:第 7 行,第 1 列: PL/SQL:忽略 SQL 语句 06550. 00000 - “第 %s 行,第 %s 列:\n%s” *原因:通常是 PL/SQL 编译错误。 *行动:
b_employee_id
156
我想使用存储在 b_employee_id 中的employee_id
【问题讨论】:
-
什么是 b_employee_id?您提供的代码中没有声明此变量的位置。而且,我相信这里缺少一个逗号:
select employee_id, first_name,street_address,city,postal_code -
您似乎错过了
employees和locations表之间的连接条件 -
@DipenduPaul
natural join将加入所有同名的列。
标签: sql database oracle11g procedural-programming procedural