【发布时间】:2017-12-20 21:34:06
【问题描述】:
有谁知道如何在 pl/sql 命令中使用来自预先存在的数据库的表和列。我正在使用 Oracles 网页中的内容作为示例。
SQL> declare
2 v_line varchar2(40):= '&v_string';
3 begin
4 v_line := 'Hello '||v_line;
5 dbms_output.put_line (v_line);
6 end;
7 /
old 2: v_line varchar2(40):= '&v_string';
New 2: v_line varchar2(40):= 'Thomas';
Hello Thomas
PL/SQL procedure successfully completed.
我希望能够从上面操作数据。假设我有一个名为 name_s 的表,我有名为 n_first 和 n_last 的列,我想使用这些列输出“Hello Thomas”,但使用这些表。
我是 pl.sql 的新手,正在尝试学习语法。
我不确定你是否可以,
DECLARE
n_first
n_last
BEGIN
SELECT * FROM name_s
n_fisrt := 'Thomas'||n_first;
dbms_output.put_line(n_first)
END;
/
Desired Output: 'Thomas'
我知道这在语法上不正确,但我只是想了解如何使用现有表中的数据来获得这种所需的输出
编辑:上表是假设的,仅包含此示例的两列。现在使用真实的表格和数据。
SET SERVEROUTPUT ON;
begin
for cur_r in (select loc_t from loc_t_matrix where store_s in(1,2,3,4,5); loop
dbms_output.put_line('Hello store' || cur_r.loc_traits );
end loop;
end;
/
上面没有编译
【问题讨论】: