我是PL \ SQL的初学者,在练习一个小代码时,我收到的错误如下
Error(7,1): PL/SQL: Statement ignored
Error(7,13): PLS-00302: component 'PUT_LINES' must be declared
Error(10,1): PL/SQL: Statement ignored
Error(10,50): PLS-00201: identifier 'LEGTH' must be declared
这是我用于练习的代码
create or replace procedure show_variable_length as
my_char char(50) := 'Hello';
my_varchar varchar(25) := 'World';
my_varchar2 varchar2(25) := 'World';
my_null_test varchar2(25);
begin
dbms_output.put_lines (my_char || ' ' || my_varchar);
dbms_output.put_line (my_char || ' ' || my_varchar2);
dbms_output.put_line('Length of my_char = ' || length(my_char));
dbms_output.put_line('Lenght of my_varchar= ' || legth(my_varchar));
dbms_output.put_line('Length of my_varchar2 = ' || length(my_varchar2));
my_char := ' ';
my_varchar := ' ';
my_varchar2 := ' ';
dbms_output.put_line ('Length of my char = ' || length(my_char));
end;
请帮忙。
答案 0 :(得分:2)
关键字长度(没有n的legth)和put_line(put_lines结尾有附加s)有拼写错误
在关键字长度中出现拼写错误
dbms_output.put_line('Lenght of my_varchar= ' || legth(my_varchar));
在put_line
中出现拼写错误dbms_output.put_lines(my_char || ' ' || my_varchar);
整改代码
create or replace procedure show_variable_length as
my_char char(50) := 'Hello';
my_varchar varchar(25) := 'World';
my_varchar2 varchar2(25) := 'World';
my_null_test varchar2(25);
begin
dbms_output.put_line(my_char || ' ' || my_varchar);
dbms_output.put_line(my_char || ' ' || my_varchar2);
dbms_output.put_line('Length of my_char = ' || length(my_char));
dbms_output.put_line('Lenght of my_varchar= ' || length(my_varchar));
dbms_output.put_line('Length of my_varchar2 = ' || length(my_varchar2));
my_char := ' ';
my_varchar := ' ';
my_varchar2 := ' ';
dbms_output.put_line('Length of my char = ' || length(my_char));
end;