running pl/sql in apex.oracle [message #627326] |
Mon, 10 November 2014 22:00 |
|
ppatel87
Messages: 5 Registered: November 2014
|
Junior Member |
|
|
Hi,
I am trying to run below pl/sql block in apex.oracle
DECLARE
v_itemname VARCHAR2(30);
BEGIN
v_itemname := '&v_item';
DBMS_OUTPUT.PUT_LINE(v_itemname);
END;
but the output i am getting is '&v_item'
while It should be prompting to ask for a value to be given by user
for v_itemname
Please can anyone help me to know that how can I make it work it in such a way that,
the user given value is assigned to v_itemname and hence the same to be printed
|
|
|
|
Re: running pl/sql in apex.oracle [message #627331 is a reply to message #627329] |
Mon, 10 November 2014 22:57 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
BlackSwan wrote on Tue, 11 November 2014 09:56
SQL> SET DEFINE OFF
OP wants the opposite of it. SET DEFINE ON
ppatel87 wrote on Tue, 11 November 2014 09:30
but the output i am getting is '&v_item'
while It should be prompting to ask for a value to be given by user
for v_itemname
SQL> set serveroutput on;
SQL> DECLARE
2 v_itemname VARCHAR2(30);
3 BEGIN
4 v_itemname := '&v_item';
5 DBMS_OUTPUT.PUT_LINE(v_itemname);
6 END;
7 /
&v_item
PL/SQL procedure successfully completed.
SQL> set define on
SQL> DECLARE
2 v_itemname VARCHAR2(30);
3 BEGIN
4 v_itemname := '&v_item';
5 DBMS_OUTPUT.PUT_LINE(v_itemname);
6 END;
7 /
Enter value for v_item: hi
old 4: v_itemname := '&v_item';
new 4: v_itemname := 'hi';
hi
PL/SQL procedure successfully completed.
SQL>
|
|
|
|
|
|
|
Re: running pl/sql in apex.oracle [message #627601 is a reply to message #627586] |
Thu, 13 November 2014 00:15 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
In that case, substitute ampersand (&) with a colon (:):
DECLARE
v_itemname VARCHAR2(30);
BEGIN
v_itemname := :v_item;
DBMS_OUTPUT.PUT_LINE(v_itemname);
END;
/
P.S. You don't need any SET command (as it is relevant for SQL*Plus, but - you don't use it anyway).
[Updated on: Thu, 13 November 2014 00:16] Report message to a moderator
|
|
|
|
|