Home » SQL & PL/SQL » SQL & PL/SQL » Using the Accept Command
Using the Accept Command [message #225224] Mon, 19 March 2007 03:56 Go to next message
rollyortiz
Messages: 4
Registered: March 2007
Junior Member
Hi,

I'm new with sqlplus and eager to learn more. I'm studying the book "Introduction to Oracle:SQL and PL/SQL" and got stuck with the "using accept command" part. I tried to do the following:

ACCEPT dept PROMPT 'Provide the department name:'
SELECT *
FROM dept
WHERE dname = UPPER('&dept')

wherein the expected output as follows:

Provide the department name: Sales

DEPTNO DNAME LOC
------- ------ -------------------
30 SALES CHICAGO

however, I received the following results instead:

SQL> ACCEPT dept PROMPT 'Provide the department name:'
Provide the department name:SELECT *
SQL> FROM dept
SP2-0042: unknown command "FROM dept" - rest of line ignored.
SQL> WHERE dname = UPPER('&dept')
SP2-0734: unknown command beginning "WHERE dnam..." - rest of line ignored.

Hoping for some answers.

Thanks




[Updated on: Mon, 19 March 2007 03:57]

Report message to a moderator

Re: Using the Accept Command [message #225237 is a reply to message #225224] Mon, 19 March 2007 04:37 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member


You have cut&pasted all the code at once....separate them

scott@UTVDB> ACCEPT dept PROMPT 'Provide the department name:'
Provide the department name:SALES

scott@UTVDB> SELECT *
2 FROM dept
3 WHERE dname = UPPER('&dept');
old 3: WHERE dname = UPPER('&dept')
new 3: WHERE dname = UPPER('SALES')

DEPTNO DNAME LOC
---------- -------------- -------------
30 SALES CHICAGO

1.Assign the value to dept
2.run the query with dept variable

Re: Using the Accept Command [message #225405 is a reply to message #225237] Mon, 19 March 2007 20:16 Go to previous message
rollyortiz
Messages: 4
Registered: March 2007
Junior Member
Ok, now it make sense to me.

Thanks
Previous Topic: Day number in a Quarter
Next Topic: one time only procedure
Goto Forum:
  


Current Time: Wed Dec 07 10:27:30 CST 2016

Total time taken to generate the page: 0.16583 seconds