Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » i really need some help!! ( unnamed blocks)
i really need some help!! ( unnamed blocks) [message #610919] Tue, 25 March 2014 23:54 Go to next message
reuben123
Messages: 4
Registered: March 2014
Location: India
Junior Member
hello! i am new to oracle and i am just starting out with the queries using oracles 11g application express ( the one that oracle lets you use for free) how ever when i write the following block i receive an error.Before writing the block i created 2 tables student (id,name,class) .Then i wrote this block

DECLARE
V_STU STUDENT%ROWTYPE;
BEGIN

V_STU.ID :=&ID;
V_STU.NAME :='&NAME';
V_STU.CLASS :='&CLASS';
INSERT INTO STUDENT VALUES V_STU;

END;

/

and i receive the following error: ORA-06550: line 5, column 12:
PLS-00103: Encountered the symbol "&" when expecting one of the following:

( - + case mod new not null

continue avg count current exists max min prior sql stddev
sum variance execute forall merge time timestamp interval
date
pipe

please help!
Re: i really need some help!! ( unnamed blocks) [message #610930 is a reply to message #610919] Wed, 26 March 2014 02:20 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum. Please read our OraFAQ Forum Guide and please read How to use [code] tags and make your code easier to read

Your code works for me:
orclz> DECLARE
  2  V_STU STUDENT%ROWTYPE;
  3  BEGIN
  4
  5  V_STU.ID :=&ID;
  6  V_STU.NAME :='&NAME';
  7  V_STU.CLASS :='&CLASS';
  8  INSERT INTO STUDENT VALUES V_STU;
  9
 10  END;
 11
 12  /
Enter value for id: 999
old   5: V_STU.ID :=&ID;
new   5: V_STU.ID :=999;
Enter value for name: john
old   6: V_STU.NAME :='&NAME';
new   6: V_STU.NAME :='john';
Enter value for class: IT
old   7: V_STU.CLASS :='&CLASS';
new   7: V_STU.CLASS :='IT';
Re: i really need some help!! ( unnamed blocks) [message #610934 is a reply to message #610930] Wed, 26 March 2014 03:08 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Where exactly did you try to run this code? SQL*Plus? Application Express' SQL Workshop? Elsewhere?
Re: i really need some help!! ( unnamed blocks) [message #611023 is a reply to message #610934] Wed, 26 March 2014 22:19 Go to previous messageGo to next message
reuben123
Messages: 4
Registered: March 2014
Location: India
Junior Member
i tried running this code on application express sql workshop, i tried it on my friends isql* environment and it worked just fine. Any idea why it wont work on application express?

ps: Thank you so much for your replies Smile
Re: i really need some help!! ( unnamed blocks) [message #611026 is a reply to message #611023] Thu, 27 March 2014 01:05 Go to previous message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As explained in Apex documentation (Using bind variables), in order to use them in SQL Workshop you have to precede them with a colon. Therefore, your code should be rewritten in the following manner:
DECLARE
  V_STU STUDENT%ROWTYPE;
BEGIN
  V_STU.ID :=:ID;
  V_STU.NAME := :NAME;
  V_STU.CLASS := :CLASS;

  INSERT INTO STUDENT VALUES V_STU;
END; 
Previous Topic: Oracle Apex
Next Topic: need some help with a code in application express
Goto Forum:
  


Current Time: Thu Mar 28 04:13:01 CDT 2024