Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help needed with SQL transaction using substitution variables

606665Nov 2 2007 — edited Nov 5 2007
Hi guys.

I'm new to this and i've already ran into some trouble. I am required to write a transaction for college. I am using Oracle Express Edition and it is giving me an error on my variables regarding the &

Below is my code:

DECLARE
accnum transactions.account_num%type:=&accnum;
tamt transactions.trans_amt%type:=&tamt;
tcomm transactions.trans_comments%type:=&tcomm;

BEGIN

INSERT INTO TRANSACTIONS VALUES (accnum, sysdate, tamt, tcomm);

UPDATE ACCOUNT_TYPE
SET balance = balance - tamt
WHERE account_num = accnum;

COMMIT;
END;


So when I declare a variable I get an error for the &.
E.g. accnum transactions.account_num%type:=&accnum;

The error is:
ORA-06550: line 2, column 39:
PLS-00103: Encountered the symbol "&" when expecting one of the following:

( - + case mod new not null


I have searched for another way of declaring a variable that prompts the user to enter it but did not find one. This is the way it was shown in college :) and I believe nobody has experienced this error in college. So could it be something to do with Oracle Database Express Edition?

Thanks,
Lewis.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2007
Added on Nov 2 2007
12 comments
794 views