views:

729

answers:

4

Here is:

declare
  v_str1   varchar2(80);
begin
  v_str1 := 'test';
  print :v_str1;
end

When I run it using SQLDeveloper just in a sql worksheet I get this:

Bind Variable "v_str1" is NOT DECLARED
anonymous block completed
A: 

Try

declare
  v_str1   varchar2(80);
begin
  v_str1 := 'test';
  print v_str1;
end
Aurelio Martin
Gives: ORA-06550
NitroxDM
+1  A: 
FrustratedWithFormsDesigner
It prompts for a value for V_str then throws an error ORA-06550. If you change it to print :V_str1; you get Bind Variable "v_str1" is NOT DECLARED.
NitroxDM
+1  A: 

Got it:

set serveroutput on

declare
  v_str1   varchar2(80);    
begin
 v_str1 := 'test';
 dbms_output.put_line(v_str1);
end;

More info here.

NitroxDM
A: 

print is not a PLSQL function. if you want to get an out put , you can use dbms_output.put_line(v_str1);

set serveroutput on;

declare v_str1 varchar2(80); begin v_str1 := 'test'; dbms_output.put_line(v_str1); end;

:v_str1 is a bind variable but you must declare not in a plsql. When you declare it you must use VARIABLE keyword.

EREN