943,709 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 9383
  • Oracle RSS
Oct 24th, 2008
0

Bind Variable Not Declared??

Expand Post »
Ok, so I'm learning about procedures and functions in Oracle and I'm stuck here with my procedure. I have the function part down pretty good, but the whole returning variables with procedures through OUT mode is confusing me. My task is this: "Write a procedure that accepts a zipcode & returns the city & state for that value as well as a "status" parameter whose value 'ok' or 'nok' includes whether or not the request was satisfied."

So here is the procedure I wrote:

Oracle Syntax (Toggle Plain Text)
  1. CREATE OR REPLACE PROCEDURE getCityState
  2. (v_zipcode IN location.zipcode%TYPE,
  3. v_city OUT location.city%TYPE,
  4. v_state OUT location.state%TYPE,
  5. v_status OUT VARCHAR2)
  6. AS
  7. BEGIN
  8. SELECT city, state INTO v_city, v_state
  9. FROM location
  10. WHERE zipcode = v_zipcode;
  11. IF SQL%FOUND THEN
  12. v_status := 'ok';
  13. END IF;
  14. EXCEPTION
  15. WHEN NO_DATA_FOUND THEN
  16. IF SQL%NOTFOUND THEN
  17. v_status := 'nok';
  18. END IF;
  19. WHEN OTHERS THEN
  20. v_status := 'nok';
  21. END getCityState;

And I'm trying to call the procedure, but I don't think I'm doing it correctly and I haven't found anything that's too terribly helpful for my dilemma. Here is my calling statement:

Oracle Syntax (Toggle Plain Text)
  1. DECLARE
  2. v_city location.city%TYPE := 0;
  3. v_state location.state%TYPE := 0;
  4. v_status VARCHAR2 := 0;
  5. BEGIN
  6. getCityState(99004, :v_city, :v_state, :v_status);
  7. END;
  8. /

I continue to get several different errors depending on how I structure the statement, but with this particular structure I am getting a "Bind variable "v_status" not declared" error. Can anyone help me and tell me what I am doing wrong, or give me a link to a site or something that can explain this a bit better to me? The lame-ass text book I have is a total piece of garbage and my instructor isn't exactly the kind of fellow who is pron to helping.

Thanks in advance!!!
Reputation Points: 11
Solved Threads: 0
Light Poster
bondo is offline Offline
43 posts
since Apr 2007
Oct 24th, 2008
1

Re: Bind Variable Not Declared??

Hi! you are calling local variable the way you should call bind variables. so oracle things your variables are bind variables. you should not use ':' sign before variable names. anyway you should write it as

declare
v_city location.city%type := 0;
v_state location.state%type := 0;
v_status varchar2 := 0;
begin
getCityState(99004, v_city, v_state, v_status);
end;
/
Reputation Points: 31
Solved Threads: 5
Light Poster
yilmazhuseyin is offline Offline
48 posts
since Oct 2006
Oct 24th, 2008
0

Re: Bind Variable Not Declared??

you need not use bind variables for that. just try to use as suggested in the previous post.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: sql
Next Thread in Oracle Forum Timeline: I'm Smarter Than Larry Ellison





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC