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!

how to declare local variable in stored procecure in oracle

833676Jan 24 2011 — edited Jan 24 2011
iam new to oracle 11g

i have a table Visit in which visitNO column is there i have a requirement that i have to fetch
maximum visitNO from the table

i have written a query

v_SETRESULT NUMBER(10,0);---- this is my variable declaration

SELECT NVL(COUNT(VisitNo), 0)
INTO v_SETRESULT---- this is my local variable declared in Stored Procedure
FROM Visit----- this is my table

when i run this query i get this error

Error starting at line 1 in command:
v_SETRESULT NUMBER(10,0);
Error report:
Unknown Command

Error starting at line 2 in command:
SELECT NVL(COUNT(VisitNo), 0)
INTO v_SETRESULT
FROM Visit
Error at Command Line:3 Column:10
Error report:
SQL Error: ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action:


and plz also tell me how to store value of a column in local variable declared in
a select query
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 21 2011
Added on Jan 24 2011
4 comments
4,404 views