2

I got a table with strings from varchar2(50) and I want to find all tuples with a name which equals to a given name.

My input part of code is

name:=&k;

(k is not declared)

but when I give a string like "Jhon" it actually uses it as value and not a string (Jhon and not 'Jhon')

so my question is how to perform a string(varchar2) input?

1
  • That is not a PL/SQL "input", it's a feature of SQL*Plus (PL/SQL can not interact with the user) Commented Jan 9, 2014 at 15:50

1 Answer 1

5

Assuming you're running an anonymous PL/SQL block from SQL*Plus (or SQL Developer), you just need to enclose the substitution variable in quotes:

name := '&k';

For example:

set verify off
set serveroutput on

declare
  name varchar2(10);
begin
  name := '&k';
  dbms_output.put_line('Name is: ' || name);
end;
/

anonymous block completed
Name is: jhon
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.